Skip to content

Commit

Permalink
Fixed auto apply coupon for smart coupon plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ChetanGN committed May 10, 2022
1 parent 3aeb37f commit abaaf45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion includes/api/coupon-apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ function applyCouponOnCart(WP_REST_Request $request)
// to clear any residual notices
$temp = wc_print_notices(true);

WC()->cart->remove_coupon($couponCode);
WC()->cart->empty_cart();

$cart1cc = create1ccCart($orderId);

WC()->cart->remove_coupon($couponCode);

if ($cart1cc) {
$applyCoupon = WC()->cart->add_discount($couponCode);
Expand Down
4 changes: 4 additions & 0 deletions includes/api/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ function createWcOrder(WP_REST_Request $request)
updateOrderStatus($orderId, 'draft');
} else {
$orderId = $woocommerce->session->get(RZP_1CC_CART_HASH . $cartHash);

//To get the applied coupon details from cart object.
$coupons = WC()->cart->get_coupons();
$couponCode = !empty($coupons)? array_key_first($coupons): null;
}
}

Expand Down

0 comments on commit abaaf45

Please sign in to comment.