How to call createRebateProducts() method in basket plugin

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
angryhans
Posts: 2
Joined: 19 Apr 2022, 23:13

How to call createRebateProducts() method in basket plugin

Post by angryhans » 05 May 2022, 10:13

Hi, I want to automaticly add a coupon code according to basket products total amount.
e.g.
When the total amount reach 100$, a coupon code with 10% off will be applied automaticly,
and when the total amount reach 200$, a coupon code with 20$ off will be appiled automaticly etc.
so the customer do not to need enter the code manually in this way. Is that possible?

I have created a basket pulgin that registered with "addProduct.after", "deleteProduct.after"
however a litter confused with how to add the specific coupon code in the update() method.

Maybe some codes like:
$rebate = $this->getConfigValue('hanscoupon.rebate', 0);
$products = $this->createRebateProducts($base, 'demo-rebate', $rebate);
$base->setCoupon($this->getCode(), $products);

I wonder how to call the createRebateProducts() within a basket plugin update() method?
Please give me some advices, thanks. :)

User avatar
aimeos
Administrator
Posts: 8636
Joined: 01 Jan 1970, 00:00

Re: How to call createRebateProducts() method in basket plugin

Post by aimeos » 06 May 2022, 05:03

You can't use createRebateProducts() in basket plugins because that method is only available in coupon providers.

The easiest way would be to create a coupon (e.g. code "10%") with "Percent" coupon provider and 10% discount and implement a basket plugin that always adds that coupon code to the basket with addCoupon() when a product is added and the coupon code haven't been added yet.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
angryhans
Posts: 2
Joined: 19 Apr 2022, 23:13

Re: How to call createRebateProducts() method in basket plugin

Post by angryhans » 06 May 2022, 07:12

OK, I will try with the addCoupon() method, thank you very much!

Post Reply