Post by stagosal » Tue Oct 18, 2016 4:25 pm

Hello there i am using Opencart 2.2 here. This method works perfectly but with one problem. I would like the user to click on a popup link and redirect to to the custom link at /index.php?coupon=XXXXX. But unfortunately if no product is in the user's cart the coupon is not applied at checkout. So the user has to have at least one product in his cart and then apply the link for the coupon to be applied. Is there a way for someone to first visit the coupon link, then add products at his cart and then at the checkout the coupon to be applied?
Thank you in advance.

Newbie

Posts

Joined
Mon Mar 28, 2016 10:35 pm

Post by JeremyColvin » Wed Feb 08, 2017 3:38 am

Qphoria wrote:Updated my first post for 2.2.x
Hi there! First, THANK YOU for taking the time to put this fix up here!

Second, I can't seem to get it to work in OpenCart 2.1.0.1 - I don't have a "framework.php" so I tried putting it in the index.php where described, but when I try the URL / coupon it does nothing.

Any thoughts?

Newbie

Posts

Joined
Wed Feb 08, 2017 3:35 am

Post by ritaylo3 » Fri May 12, 2017 11:53 pm

Hi,
I tried adding the 2.2 code in framework.php of 2.3.0.2 and it doesn't work. Does anyone have a solution for 2.3.0.2?
Thanks,
ritaylo3

Newbie

Posts

Joined
Tue May 22, 2012 3:48 am

Post by Sokonomi » Sat Mar 31, 2018 3:32 pm

I'm lurking the forum for a solution like this for 3.0.2.0. Any chance one of you know how to slip this trick into that version?

Active Member

Posts

Joined
Sun Sep 30, 2012 4:52 am

Post by straightlight » Sat Mar 31, 2018 9:14 pm

OC v3.0.2.0 . In catalog/controller/startup/startup.php file,

find:

Code: Select all

// Currency
add above:

Code: Select all

// Coupon
if (!empty($this->request->get['coupon'])) {
	$this->session->data['coupon'] = strip_tags(html_entity_decode(trim($this->request->get['coupon']), ENT_QUOTES, 'UTF-8'));
}
Then, in system/framework.php file,

find:

Code: Select all

// Dispatch
Add above:

Code: Select all

// Coupon in url
if (!empty($_GET['coupon'])) {
   $session->data['coupon'] = strip_tags(html_entity_decode(trim($_GET['coupon']), ENT_QUOTES, 'UTF-8'));
}
This should resolved the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by kaliyas » Sat Aug 22, 2020 8:00 pm

This was really helpful !
Thanks a lot

New member

Posts

Joined
Sat Dec 17, 2011 6:36 pm

Post by aitechbg » Mon Nov 21, 2022 6:38 pm

OCMOD from what straightlight says :) All credits to straightlight!


<modification>
<name>Coupon and affilate via url</name>
<version>1.0.0</version>
<link>https://forum.opencart.com</link>
<author><![CDATA[Coupon and affilate via url]]></author>
<code>coupon_affilate_via_url</code>

<file path="catalog/controller/startup/startup.php" error="skip" info="Coupon and affilate via url">
<operation>
<search><![CDATA[// Currency]]></search>
<add position="before"><![CDATA[
// Coupon
if (!empty($this->request->get['coupon'])) {
$this->session->data['coupon'] = strip_tags(html_entity_decode(trim($this->request->get['coupon']), ENT_QUOTES, 'UTF-8'));
}
]]></add>
</operation>
</file>
<file path="system/framework.php" error="skip" info="Coupon and affilate via url">
<operation>
<search><![CDATA[// Dispatch]]></search>
<add position="before"><![CDATA[
// Coupon in url
if (!empty($_GET['coupon'])) {
$session->data['coupon'] = strip_tags(html_entity_decode(trim($_GET['coupon']), ENT_QUOTES, 'UTF-8'));
}
]]></add>
</operation>
</file>
</modification>

Web Development, Consulting and SEO for Europe by itech.bg


Newbie

Posts

Joined
Mon Mar 27, 2017 8:51 pm

Post by Georgee » Thu Jun 13, 2024 8:32 pm

In Opencart 3.0.3.9 PHP 8.1 there is an error 404 "Too many redirects" when adding this OCMOD. The discount code is applied but page is white.
Can anyone help?

Newbie

Posts

Joined
Mon Nov 15, 2010 9:24 pm

Post by ADD Creative » Thu Jun 13, 2024 10:23 pm

Georgee wrote:
Thu Jun 13, 2024 8:32 pm
In Opencart 3.0.3.9 PHP 8.1 there is an error 404 "Too many redirects" when adding this OCMOD. The discount code is applied but page is white.
Can anyone help?
Check both your OpenCart and PHP error logs.

www.add-creative.co.uk


Expert Member

Posts

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

Post by Georgee » Wed Jul 10, 2024 5:25 pm

ADD Creative wrote:
Thu Jun 13, 2024 10:23 pm
Georgee wrote:
Thu Jun 13, 2024 8:32 pm
In Opencart 3.0.3.9 PHP 8.1 there is an error 404 "Too many redirects" when adding this OCMOD. The discount code is applied but page is white.
Can anyone help?
Check both your OpenCart and PHP error logs.
In Opencart Log nothing added when this error occurs.
In PHP logs just 20x Code 301 GET /?coupon=XXXXX HTTP/1.0
No errors. Any idea how to solve this?

Newbie

Posts

Joined
Mon Nov 15, 2010 9:24 pm

Post by ADD Creative » Wed Jul 10, 2024 6:50 pm

Georgee wrote:
Wed Jul 10, 2024 5:25 pm
In Opencart Log nothing added when this error occurs.
In PHP logs just 20x Code 301 GET /?coupon=XXXXX HTTP/1.0
No errors. Any idea how to solve this?
I've just tested the post code and it did work fine. However it has an XSS vulnerability so I would remove the code immediately.

It looks like you have a redirect somewhere when ?coupon=XXXXX is in the URL, maybe in your htaccess.

www.add-creative.co.uk


Expert Member

Posts

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

Users browsing this forum: No registered users and 22 guests