issues on assigning coupon code into an order
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!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 11
- Joined: 14 Jun 2021, 05:59
issues on assigning coupon code into an order
"php": "^7.3|^8.0",
"aimeos/aimeos-laravel": "~2021.07",
Hi
Iam trying to assign coupon to an order , i used the code below ,but it is turning the order price into zero, also i have some other questions (because i could not find any documentation) :
1- what is the exact function to assign the coupon into an order
2-does the function update the price based on percent/fixed price of the coupon automatically or I need to update it by myself?
3-does it show up in admin panel->view order/ about the coupon discount price?
I appreciate any help <3
"aimeos/aimeos-laravel": "~2021.07",
Hi
Iam trying to assign coupon to an order , i used the code below ,but it is turning the order price into zero, also i have some other questions (because i could not find any documentation) :
Code: Select all
$setCoupon = $baseItem->setCoupon($request->code, $productMap);
$baseManager->store($setCoupon);
2-does the function update the price based on percent/fixed price of the coupon automatically or I need to update it by myself?
3-does it show up in admin panel->view order/ about the coupon discount price?
I appreciate any help <3
Re: issues on assigning coupon code into an order
You shouldn't use that method by yourself because it's not guaranteed that something will happen. This is the task of the coupon providers whose implementations you can see here:
https://github.com/aimeos/aimeos-core/t ... n/Provider
https://github.com/aimeos/aimeos-core/t ... n/Provider
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
-
- Posts: 11
- Joined: 14 Jun 2021, 05:59
Re: issues on assigning coupon code into an order
Can i ask for some documents about how can i assign a coupon code into an order and update the prices of the order based on the values added into the voucher config?
cause i dont know what u mean by providers , and there is lot of files and functions.
There is a section in admin panel that Admin can define codes and fixed/percent discount , so when i use a function , it can check the coupon code and assign the discount into the order.
cause i dont know what u mean by providers , and there is lot of files and functions.
There is a section in admin panel that Admin can define codes and fixed/percent discount , so when i use a function , it can check the coupon code and assign the discount into the order.
Re: issues on assigning coupon code into an order
Unfortunately, the coupon providers are currently one of the parts that's not documented yet.Kappa.yahyya wrote: ↑30 Sep 2021, 13:27 Can i ask for some documents about how can i assign a coupon code into an order and update the prices of the order based on the values added into the voucher config?
cause i dont know what u mean by providers , and there is lot of files and functions.
A coupon provider is a class that contains the code to add and update the basket based on the desired algorithm similar to service providers which handle payments or pass orders to 3rd party systems. Documentation for service providers is available here and may give you a better understanding of providers in general:
https://aimeos.org/docs/latest/providers/service/
From the existing coupon providers, the "Present" coupon provider is a very simple one and easy to understand. It only adds a configured product to the order for free:
https://github.com/aimeos/aimeos-core/b ... resent.php
The interesting part is the update() method which handles adding the product to the basket:
https://github.com/aimeos/aimeos-core/b ... hp#L78-L92
You only have to care about adding the product here. There's code in the coupon provider infrastructure that cares about removing added products automatically if the coupon is not available any more, e.g. because the the minimum basket value is not reached (not in the basket setCoupon() method!).
Yes, check the manual: https://aimeos.org/docs/latest/manual/coupon-details/Kappa.yahyya wrote: ↑30 Sep 2021, 13:27 There is a section in admin panel that Admin can define codes and fixed/percent discount , so when i use a function , it can check the coupon code and assign the discount into the order.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star