Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Coupon Code cannot be used in conjunction with a custom order adjustment "discount" #3321

Open
philipboomy opened this issue Nov 1, 2023 · 5 comments
Assignees
Labels
bug commerce4 Issues related to Commerce v4 🔎 status: investigating Trying to reproduce ℹ️ status: need more info When waiting for user to supply database or more information.

Comments

@philipboomy
Copy link

What happened?

Description

Not sure if its classed as a bug but here goes.

In some cases the client need to be able to use a coupon code on orders where there is a custom adjustment "discount".

Whenever he enters the coupon code it removes the custom adjuster making it impossible to have both. Please see attached screenshots.

after-coupon
before-coupon

Is it possible to have both somehow?

Craft CMS version

4.5.9

Craft Commerce version

4.3.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@philipboomy philipboomy added commerce4 Issues related to Commerce v4 bug labels Nov 1, 2023
@AugustMiller
Copy link
Contributor

Is it possible that the conditions for the coupon and adjuster (or their calculations) conflict or are mutually exclusive?

Adjusters are applied in a consistent order (based on how they're registered), and may depend on previous adjustments at the time they're evaluated against the order. Are you able to share the full adjuster class, and your Event::on() block where it's registered?

@philipboomy
Copy link
Author

Hi August,

Thanks for looking into it. I cant see anything that would cause a conflict except the adjuster is a "discount" one.

class GiftCardAdjuster extends Component implements AdjusterInterface
{
    public function adjust(Order $order): array
    {
        $adjustment = new OrderAdjustment();

        $adjustment->type = 'discount';
        $adjustment->name = 'Gift Card';
        $adjustment->amount = 10;

        $adjustment->setOrder($order);

        return [$adjustment];
    }
}
Event::on(OrderAdjustments::class, OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS,
            function(RegisterComponentTypesEvent $event) {
              $event->types[] = GiftCardAdjuster::class;
            }
        );
 

@lukeholder
Copy link
Member

Ill attempt to reproduce using your example. Thanks.

@lukeholder
Copy link
Member

I tried to reproduce and I could not:

CleanShot.2023-11-08.at.14.53.14.mp4

CleanShot 2023-11-08 at 14 57 07@2x

Let me know if I missed anything.

I am inclined to agree with August that maybe the custom adjuster is more complicated and logic is conflicting with the built-in discount rules.

@lukeholder lukeholder added ℹ️ status: need more info When waiting for user to supply database or more information. 🔎 status: investigating Trying to reproduce labels Nov 8, 2023
@philipboomy
Copy link
Author

Thanks for looking into this. Could you try via the admin panel? Sorry I should have mentioned that we are only applying coupon codes via admin panel.

I did just test frontend and I can get it working like you but not via admin panel.

@lukeholder lukeholder self-assigned this Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4 🔎 status: investigating Trying to reproduce ℹ️ status: need more info When waiting for user to supply database or more information.
Projects
None yet
Development

No branches or pull requests

3 participants