Post by kiwi11 » Wed Nov 14, 2018 2:36 pm

Hello,

I am using OpenCart's PayPal Express Checkout module. When on the final confirmation page before submitting the order, there is a field to enter a coupon code. When you apply a coupon, the entire transaction is redirected to the shopping cart. You then have to login to PayPal again to get back to the confirmation page.

What edit can be made so that upon applying the coupon code, the user stays on the same page and doesn't have to repeat the checkout process?

Thank you!

Newbie

Posts

Joined
Wed Nov 14, 2018 2:29 pm

Post by ADD Creative » Wed Nov 14, 2018 7:54 pm

The strange thing is, that there seems to be code to handle the coupon on the PayPal Express Checkout page.
https://github.com/opencart/opencart/bl ... #L358-L365

However, the coupon template has the POST URL hardcoded the the standard coupon controller.
https://github.com/opencart/opencart/bl ... n.twig#L16

You would have to change the POST URL to the PayPal Express Checkout page, but only for PayPal Express payment methods. Or add your own controller and template just for PayPal Express.

A different method may be to change the redirect in the coupon controller to redirect to the PayPal Express Checkout page, but again only for PayPal Express payment methods.
https://github.com/opencart/opencart/bl ... on.php#L41

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by kiwi11 » Thu Nov 15, 2018 5:56 am

ADD Creative wrote:
Wed Nov 14, 2018 7:54 pm
The strange thing is, that there seems to be code to handle the coupon on the PayPal Express Checkout page.
https://github.com/opencart/opencart/bl ... #L358-L365

However, the coupon template has the POST URL hardcoded the the standard coupon controller.
https://github.com/opencart/opencart/bl ... n.twig#L16

You would have to change the POST URL to the PayPal Express Checkout page, but only for PayPal Express payment methods. Or add your own controller and template just for PayPal Express.

A different method may be to change the redirect in the coupon controller to redirect to the PayPal Express Checkout page, but again only for PayPal Express payment methods.
https://github.com/opencart/opencart/bl ... on.php#L41
Hello ADD Creative,

Thank you for this, it was very helpful and you identified the cause of this issue.

Which of the modifications you suggested do you think is the best option, and what is the exact modification should be performed? I appreciate it.

Newbie

Posts

Joined
Wed Nov 14, 2018 2:29 pm

Post by ADD Creative » Fri Nov 16, 2018 6:13 am

I think the best option would be to add a new controller and template, based on catalog/controller/extension/total/coupon.php and catalog/view/theme/default/template/extension/total/coupon.twig. Renaming the relevant parts such as the class name, redirect URL and POST URL.

Then changing the coupon controller in PayPal Express to your new one.
https://github.com/opencart/opencart/bl ... s.php#L721

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by ADD Creative » Fri Nov 16, 2018 11:53 pm

I've made a extension with the changes, tested on 3.0.2.0. Undo any changes you have made and upload the file with the extension installer. Then refresh both the modifications cache (Extensions->Modifications->Refresh) and the template cache (blue button top right of dashboard).

Attachments


www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by kiwi11 » Sat Nov 17, 2018 2:32 am

ADD Creative wrote:
Fri Nov 16, 2018 11:53 pm
I've made a extension with the changes, tested on 3.0.2.0. Undo any changes you have made and upload the file with the extension installer. Then refresh both the modifications cache (Extensions->Modifications->Refresh) and the template cache (blue button top right of dashboard).
Thank you for putting this together, that will really help users on 3.0.2.0. However, I should have mentioned before (my mistake!), the store in this case is on 2.3.0.2 and is using the Journal theme. The code is essentially the same and hasn't changed much, so I tried to do the few necessary changes to adapt your modification for this store. Unfortunately, I still can't seem to get it to work. Thank you again!

Newbie

Posts

Joined
Wed Nov 14, 2018 2:29 pm

Post by ADD Creative » Sat Nov 17, 2018 6:52 am

You did post in the section of the forums for version 3. I've modified for version 2.3. Please fully test as I have only quickly tested.

Attachments


www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by kiwi11 » Sat Nov 17, 2018 9:06 am

ADD Creative wrote:
Sat Nov 17, 2018 6:52 am
You did post in the section of the forums for version 3. I've modified for version 2.3. Please fully test as I have only quickly tested.
Yes, I see that now, my mistake.

The great news is that your extension is working great! Thank you for this, I really appreciate it.

Do you know how a coupon can be removed once it is applied, as I did not see how to do this?

Thank you.

Newbie

Posts

Joined
Wed Nov 14, 2018 2:29 pm

Post by ADD Creative » Sat Nov 17, 2018 11:16 pm

I could be wrong, but I don't think you can, other than maybe removing cart contents or logging out.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by kiwi11 » Sun Nov 18, 2018 7:47 am

ADD Creative wrote:
Sat Nov 17, 2018 11:16 pm
I could be wrong, but I don't think you can, other than maybe removing cart contents or logging out.
Got it, thank you for your help!

Newbie

Posts

Joined
Wed Nov 14, 2018 2:29 pm
Who is online

Users browsing this forum: No registered users and 19 guests