Skip to content

Commit

Permalink
coupon code fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bozhidar Slaveykov committed Oct 27, 2021
1 parent af99004 commit 89d1cdb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/MicroweberPackages/Cart/CartManager.php
Expand Up @@ -31,17 +31,12 @@ public function __construct($app = null)
}

$coupon_code = $this->app->user_manager->session_get('coupon_code');
/* $this->coupon_data = db_get("cart_coupons", array(
'is_active' => 1,
'coupon_code' => $coupon_code,
'single' => true,
'no_cache' => true
));*/
$this->coupon_data = coupon_get_by_code($coupon_code);
}

/**
* This will sum all cart items amount
* @param bool $return_amount
*
* @return array|false|float|int|mixed
*/
public function sum($return_amount = true)
Expand Down Expand Up @@ -187,7 +182,7 @@ public function get_discount()

public function get_discount_type()
{
if (empty( $this->coupon_data)) {
if (empty($this->coupon_data)) {
return false;
}

Expand All @@ -196,17 +191,17 @@ public function get_discount_type()

public function get_discount_value()
{
if (empty( $this->coupon_data)) {
if (empty($this->coupon_data)) {
return false;
}

$apply_code = false;
if ($this->total() >= $this->coupon_data['total_amount']) {
if ($this->sum() >= $this->coupon_data['total_amount']) {
$apply_code = true;
}

if ($apply_code) {
return floatval( $this->coupon_data['discount_value']);
return floatval($this->coupon_data['discount_value']);
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions userfiles/modules/shop/coupons/functions.php
Expand Up @@ -296,7 +296,7 @@ function coupons_delete_session()
print '<module type="shop/coupons" view="admin_block" />';
});


/*
event_bind('mw.shop.cart.init', function ($params) {
//register_component($type,$params)
Expand All @@ -310,6 +310,6 @@ function coupons_delete_session()
});

*/


0 comments on commit 89d1cdb

Please sign in to comment.