VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: noOob on December 19, 2018, 17:03:32 PM

Title: Removing coupons on specific payment
Post by: noOob on December 19, 2018, 17:03:32 PM
Hi,
As i mentioned in the subject i need a way to remove all the coupons on a specific payment. Like there are no coupon usable for "pay with cash".  I tried to implement it using javascript, in the way that when user change payment method and if it is "pay with cash" i try to call all the remove button links and then remove the coupon area preventing more coupon input. but there are many bugs this way, first it does not work for more than one coupons and i know why, second it is client area checking which is not very reliable and more.

The reason behind first bug is (as i know) coupon data like any other cart data are in joomla session and if we imagine it as a resource there happens race condition on this resource and that's the exact reason the virtuemart is made like everything are updating through Ajax but Coupon removal.

I need a way to remove them or alternatively if it's possible don't accept it on order submission or sth like these.
Title: Re: Removing coupons on specific payment
Post by: GJC Web Design on December 19, 2018, 17:29:18 PM
I guess ajax is the way to go .. when forbidden payment it sends an ajax call to remove the coupon from the session and trigger a recalc?

of use JS to remove the field value and resubmit the cart to force a recalc?
Title: Re: Removing coupons on specific payment
Post by: jenkinhill on December 19, 2018, 17:29:32 PM
Awocoupon (https://awodev.com/products/joomla/awocoupon) has an "Option to restrict coupon by payment method"
Title: Re: Removing coupons on specific payment
Post by: GJC Web Design on December 19, 2018, 18:11:14 PM
ah!  perfect
Title: Re: Removing coupons on specific payment
Post by: noOob on December 19, 2018, 18:43:07 PM
Quote from: jenkinhill on December 19, 2018, 17:29:32 PM
Awocoupon (https://awodev.com/products/joomla/awocoupon) has an "Option to restrict coupon by payment method"

nice, I'm using awocoupon, but a poor translation made it hard for me, it was mistranslated so i couldn't find payment method restriction option.

now there is only one problem, it's per coupon, i want to do it for all coupons :D if it had a configuration or sth so that applied on all coupons it was way better for me.
Title: Re: Removing coupons on specific payment
Post by: Jörgen on December 19, 2018, 19:41:12 PM
Talk to awocoupon about this
Jörgen @ Kreativ Fotografi