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.
Hi there! First, THANK YOU for taking the time to put this fix up here!Qphoria wrote:Updated my first post for 2.2.x
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?
OC v3.0.2.0 . In catalog/controller/startup/startup.php file,
find:
add above:
Then, in system/framework.php file,
find:
Add above:
This should resolved the issue.
find:
Code: Select all
// Currency
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'));
}
find:
Code: Select all
// Dispatch
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'));
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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>
<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
Who is online
Users browsing this forum: No registered users and 68 guests