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
Who is online

Users browsing this forum: paulfeakins and 78 guests