What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Is there a good way to programmatically apply a discount to an order during checkout?

U03T08LE3CP
U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

Is there a good way to programmatically apply a discount to an order during checkout?

Comments

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet

    Spryker has to types of discounts:
    β€’ Cart rules: the discount will be applied automatically to the products based on set rules;
    β€’ Voucher codes: the discount will be applied to the products based on set rules and when a voucher is added.
    Seems like cart rules is exactly what you want.
    Here's the documentation on how to create discounts: https://docs.spryker.com/docs/pbc/all/discount-management/manage-in-the-back-office/create-discounts.html#prerequisites

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited November 2022

    yeah I'm looking at cart rules but I'm struggling to figure out how to apply them. We have loyalty cards (number only) that give you some discount, and the customer is not registered

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet

    These plugins add more options to select in the discount configuration.

    How does these loyalty cards work? Like voucher codes?

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    well kinda. If you have one you are entitled to some discount and the number is always the same

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    (same per user that is)

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet

    So it's a voucher code with unlimited uses?

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    yes

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    and hundreds of thousands of valid numbers

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet

    And how are you currently storing these loyalty codes?

    It's sounding like you are going to have to create new decision rules

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    the codes are in a separate system

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited November 2022

    I can ask it if the code is valid

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    the codes are personal and I can also validate that it's with the correct person

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    all I need for Spryker is to say "ok this ruleset is now valid" after that

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet

    Yeah, exactly. You are going to need to create a new decision rule plugin.

    the decision rule plugin implements the method isSatisfiedBy($quoteTransfer, $itemTransfer, $clauseTransfer): bool

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet

    You just need to check how are you going to implement the form where the user will add the loyalty code

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    we have a custom frontend

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    so I suppose it comes from somewhere(tm) through the Glue API πŸ˜…

  • U01K43ADW5N
    U01K43ADW5N Posts: 69 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited November 2022

    Maybe you can also think of implementing this loyalty code as a Payment option, like the spryker's Gift Codes.

    In our project we've implemented a loyalty points program and it works almost exactly as gift codes.

  • U03T08LE3CP
    U03T08LE3CP Posts: 185 πŸ§‘πŸ»β€πŸš€ - Cadet

    I think the discount rule system sounds like the way to try at least first. Thanks!