Hello everyone.
Can coupon code be applied to the basic price of the product instead of the discount price?
Any feedback is greatly appreciated..
Version 3.0.3.8
Thank you.
Can coupon code be applied to the basic price of the product instead of the discount price?
Any feedback is greatly appreciated..
Version 3.0.3.8
Thank you.
- https://www.opencart.com/index.php?rout ... n_id=26976nureddin21 wrote: ↑Tue Apr 05, 2022 7:44 amHello everyone.
Can coupon code be applied to the basic price of the product instead of the discount price?
Any feedback is greatly appreciated..
Version 3.0.3.8
Thank you.
- https://www.opencart.com/index.php?rout ... n_id=26977
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I know these extensions from Jonathan..straightlight wrote: ↑Tue Apr 05, 2022 8:07 am- https://www.opencart.com/index.php?rout ... n_id=26976nureddin21 wrote: ↑Tue Apr 05, 2022 7:44 amHello everyone.
Can coupon code be applied to the basic price of the product instead of the discount price?
Any feedback is greatly appreciated..
Version 3.0.3.8
Thank you.
- https://www.opencart.com/index.php?rout ... n_id=26977
I need help from here...
Thanks for your speed reply.
While your first post does not address that, it does state that: Any feedback is greatly appreciated. You have two feedbacks, so far.nureddin21 wrote: ↑Tue Apr 05, 2022 8:11 amI know these extensions from Jonathan..straightlight wrote: ↑Tue Apr 05, 2022 8:07 am- https://www.opencart.com/index.php?rout ... n_id=26976nureddin21 wrote: ↑Tue Apr 05, 2022 7:44 amHello everyone.
Can coupon code be applied to the basic price of the product instead of the discount price?
Any feedback is greatly appreciated..
Version 3.0.3.8
Thank you.
- https://www.opencart.com/index.php?rout ... n_id=26977
I need help from here...
Thanks for your speed reply.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
The logic of this function must be changed upload\catalog\model\extension\total\coupon.php -> gettotal() function,
because the default system saves data in the cart table with a discount.
ex( mainprice 100 - discount 10% ) result-> total=90
And saves the total value 90 in the cart table and applies the coupon to the total value (90).
because the default system saves data in the cart table with a discount.
ex( mainprice 100 - discount 10% ) result-> total=90
And saves the total value 90 in the cart table and applies the coupon to the total value (90).
change this code in upload\catalog\model\extension\total\coupon.php -> gettotal() function
if ($status) {
if ($coupon_info['type'] == 'F') {
$discount = $coupon_info['discount'] * ($product['total'] / $sub_total);
} elseif ($coupon_info['type'] == 'P') {
$discount = $product['total'] / 100 * $coupon_info['discount'];
}
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
to this code
if ($status) {
$product_total = $this->db->query("SELECT p.price FROM " . DB_PREFIX . "product p WHERE p.product_id = '" . (int)$product['product_id'] . "'");
if ($coupon_info['type'] == 'F') {
$discount = $coupon_info['discount'] * ((float)$product_total->row['price'] / $sub_total);
} elseif ($coupon_info['type'] == 'P') {
$discount = (float)$product_total->row['price'] / 100 * $coupon_info['discount'];
}
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
if ($status) {
if ($coupon_info['type'] == 'F') {
$discount = $coupon_info['discount'] * ($product['total'] / $sub_total);
} elseif ($coupon_info['type'] == 'P') {
$discount = $product['total'] / 100 * $coupon_info['discount'];
}
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
to this code
if ($status) {
$product_total = $this->db->query("SELECT p.price FROM " . DB_PREFIX . "product p WHERE p.product_id = '" . (int)$product['product_id'] . "'");
if ($coupon_info['type'] == 'F') {
$discount = $coupon_info['discount'] * ((float)$product_total->row['price'] / $sub_total);
} elseif ($coupon_info['type'] == 'P') {
$discount = (float)$product_total->row['price'] / 100 * $coupon_info['discount'];
}
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['total'] - ($product['total'] - $discount), $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if ($tax_rate['type'] == 'P') {
$total['taxes'][$tax_rate['tax_rate_id']] -= $tax_rate['amount'];
}
}
}
}
So create a function in the model file for the sql query and load this model and call that function
-> $product_total = $this->db->query("SELECT p.price FROM " . DB_PREFIX . "product p WHERE p.product_id = '" . (int)$product['product_id'] . "'");
-> $product_total = $this->db->query("SELECT p.price FROM " . DB_PREFIX . "product p WHERE p.product_id = '" . (int)$product['product_id'] . "'");
Well just ask him then, he's incredibly helpful.nureddin21 wrote: ↑Tue Apr 05, 2022 8:11 amI know these extensions from Jonathan..straightlight wrote: ↑Tue Apr 05, 2022 8:07 am- https://www.opencart.com/index.php?rout ... n_id=26976
- https://www.opencart.com/index.php?rout ... n_id=26977
I need help from here...
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
It worked for me, and the discount was applied to the price before the discount.phpscript7 wrote: ↑Tue Apr 05, 2022 2:09 pmWhen you apply a coupon, get the total of the product and apply the coupon on it
But It had a new problem. In this case, the price of the product still appears after the discount. The customer gets the discount twice.
Is it possible to get the price of the product before the discount only if a coupon code is applied?
for example
Product x, price is $200 and there is a discount on it to become $100
If no coupon is applied, price still $100, but if a coupon code is applied, the price appears before the discount is $200, and the coupon is applied to this number while still calculating it in the totals correctly.
That is, forcing the customer to take advantage of one discount (either product discount or coupon discount)
You simply need to apply a rule. Those two extensions I provided on the above does have the functionality.nureddin21 wrote: ↑Tue Apr 05, 2022 7:51 pmIt worked for me, and the discount was applied to the price before the discount.phpscript7 wrote: ↑Tue Apr 05, 2022 2:09 pmWhen you apply a coupon, get the total of the product and apply the coupon on it
But It had a new problem. In this case, the price of the product still appears after the discount. The customer gets the discount twice.
Is it possible to get the price of the product before the discount only if a coupon code is applied?
for example
Product x, price is $200 and there is a discount on it to become $100
If no coupon is applied, price still $100, but if a coupon code is applied, the price appears before the discount is $200, and the coupon is applied to this number while still calculating it in the totals correctly.
That is, forcing the customer to take advantage of one discount (either product discount or coupon discount)
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: Majestic-12 [Bot], Semrush [Bot] and 59 guests