- Posts: 4
- Thank you received: 0
Access level is not assigned with 100% coupon
11 years 8 months ago #187853
by Cenacchi
Access level is not assigned with 100% coupon was created by Cenacchi
-- HikaShop version -- : 1.5.8
-- Joomla version -- : 2.5.4
Hi,
I have an old version of Hikashop that I can't update at the moment.
Anyhow, everything works perfectly except this scenario:
1) I have created a product (no category assigned) and I have set a specific user group to be assigned to the user AFTER the purchase.
2) When the user completes the payment everything works perfectly and the user is correctly assigned to the new user group.
3) If now I want to create a coupon that covers the whole price for the product (100% coupon) as a gift for certain users, once he/she has completed the payment (price set to 0 Euro and no redirect to Paypal) the order is correctly set to "confirmet" but the user IS NOT assigned to the "after purchase access level".
Can you give some hints about how to solve this ?
Thanks
Elena
-- Joomla version -- : 2.5.4
Hi,
I have an old version of Hikashop that I can't update at the moment.
Anyhow, everything works perfectly except this scenario:
1) I have created a product (no category assigned) and I have set a specific user group to be assigned to the user AFTER the purchase.
2) When the user completes the payment everything works perfectly and the user is correctly assigned to the new user group.
3) If now I want to create a coupon that covers the whole price for the product (100% coupon) as a gift for certain users, once he/she has completed the payment (price set to 0 Euro and no redirect to Paypal) the order is correctly set to "confirmet" but the user IS NOT assigned to the "after purchase access level".
Can you give some hints about how to solve this ?
Thanks
Elena
Please Log in or Create an account to join the conversation.
11 years 8 months ago #187862
by Jerome
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Replied by Jerome on topic Access level is not assigned with 100% coupon
Hi,
Regarding the fact that HikaShop 1.5.8 has been release in May 2012 and we made a lot of improvements in HikaShop during this (nearly) 3 last years, it will be complicated to know.
I think that the issue is link to the "validate free order + group after purchase" plugin.
The two plugins are using same triggers but if the "validate free order" update the order after the "group" without relaunching a trigger ; the "group" plugin can't be notify that the order is confirmed (and so, update the user group).
Having more recent version of the plugins could be useful but I don't think that they would be compatible with HikaShop 1.5.8.
Regards,
Regarding the fact that HikaShop 1.5.8 has been release in May 2012 and we made a lot of improvements in HikaShop during this (nearly) 3 last years, it will be complicated to know.
I think that the issue is link to the "validate free order + group after purchase" plugin.
The two plugins are using same triggers but if the "validate free order" update the order after the "group" without relaunching a trigger ; the "group" plugin can't be notify that the order is confirmed (and so, update the user group).
Having more recent version of the plugins could be useful but I don't think that they would be compatible with HikaShop 1.5.8.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
11 years 8 months ago #188174
by Cenacchi
Replied by Cenacchi on topic Access level is not assigned with 100% coupon
Hi,
Thanks for pointing me to the right (I think) direction. I solved in this way:
1) Inside the validate_free_orders plugin, file validate_free_orders.php I changed the status from "confirmed" to "free" inside the onAfterOrderCreate and onBeforeOrderCreate functions:
Then inside administrator/component/com_hikashop/classes/order.php I inserted a check for the "free" status after the onAfterOrderCreate trigger and, in that case, I inserted the change of the status to confirmed and the trigger of the onAfterOrderUpdate event, that is, at line 153 in my file:
In fact, the plugin that changes the group correctly wait that the payment is received: the order is pending when it's created and become confirmed after the payment, so the plugin is linked to the onAfterOrderUpdate event.
Instead, when the order is free, then it "is born" confirmed, and the onAfterOrderUpdate event is not triggered.
Now it works, but please let me know if you should see any possible problem arising from this solution.
Thanks again
Elena
Thanks for pointing me to the right (I think) direction. I solved in this way:
1) Inside the validate_free_orders plugin, file validate_free_orders.php I changed the status from "confirmed" to "free" inside the onAfterOrderCreate and onBeforeOrderCreate functions:
Code:
function onBeforeOrderCreate(&$order,&$send_email){
if(empty($order) || !isset($order->order_full_price))
return;
if(bccomp($order->order_full_price,0,5)==0){
//$order->order_status = 'confirmed'; Elena
$order->order_status = 'free';
}
}
function onAfterOrderCreate(&$order){
//if($order->order_status == 'confirmed'){ Elena
if ($order->order_status == 'free') {
$class = hikashop_get('class.cart');
$class->cleanCartFromSession();
}
}
Then inside administrator/component/com_hikashop/classes/order.php I inserted a check for the "free" status after the onAfterOrderCreate trigger and, in that case, I inserted the change of the status to confirmed and the trigger of the onAfterOrderUpdate event, that is, at line 153 in my file:
Code:
$dispatcher->trigger( 'onAfterOrderCreate', array( & $order,&$send_email) );
//Elena
if ($order->order_status == 'free') {
$order->order_status = 'confirmed';
$dispatcher->trigger( 'onAfterOrderUpdate', array( & $order,&$send_email) );
}
//Elena
if($send_email){
In fact, the plugin that changes the group correctly wait that the payment is received: the order is pending when it's created and become confirmed after the payment, so the plugin is linked to the onAfterOrderUpdate event.
Instead, when the order is free, then it "is born" confirmed, and the onAfterOrderUpdate event is not triggered.
Now it works, but please let me know if you should see any possible problem arising from this solution.
Thanks again
Elena
Please Log in or Create an account to join the conversation.
Time to create page: 0.185 seconds