Removed the option of BuyAGetB as its current functionality was same as Fixed amount

This commit is contained in:
Prashant Singh 2019-06-27 18:34:37 +05:30
parent 216b409531
commit 4db41973fd
3 changed files with 19 additions and 17 deletions

View File

@ -34,7 +34,7 @@ return [
'actions' => [
'percent_of_product' => 'Percentage of product',
'fixed_amount' => 'Apply as fixed amount',
'buy_a_get_b' => 'Buy A get B'
// 'buy_a_get_b' => 'Buy A get B'
],
'validation' => [

View File

@ -597,23 +597,25 @@ abstract class Discount
*/
public function applyOnShipping($appliedRule, $cart)
{
if ($appliedRule->free_shipping && $cart->selected_shipping_rate->base_price > 0) {
$cart->selected_shipping_rate->update([
'price' => 0,
'base_price' => 0
]);
} else if ($appliedRule->free_shipping == 0 && $appliedRule->apply_to_shipping && $cart->selected_shipping_rate->base_price > 0) {
$actionType = config('discount-rules')[$appliedRule->action_type];
if ($appliedRule->apply_to_shipping) {
$actionInstance = new $actionType;
$discountOnShipping = $actionInstance->calculateOnShipping($cart);
if (isset($cart->selected_shipping_rate->base_price)) {
if ($appliedRule->free_shipping && $cart->selected_shipping_rate->base_price > 0) {
$cart->selected_shipping_rate->update([
'price' => $cart->selected_shipping_rate->base_price - $discountOnShipping,
'base_price' => $cart->selected_shipping_rate->price - core()->convertPrice($discountOnShipping, $cart->cart_currency_code)
'price' => 0,
'base_price' => 0
]);
} else if ($appliedRule->free_shipping == 0 && $appliedRule->apply_to_shipping && $cart->selected_shipping_rate->base_price > 0) {
$actionType = config('discount-rules')[$appliedRule->action_type];
if ($appliedRule->apply_to_shipping) {
$actionInstance = new $actionType;
$discountOnShipping = $actionInstance->calculateOnShipping($cart);
$cart->selected_shipping_rate->update([
'price' => $cart->selected_shipping_rate->base_price - $discountOnShipping,
'base_price' => $cart->selected_shipping_rate->price - core()->convertPrice($discountOnShipping, $cart->cart_currency_code)
]);
}
}
}
}

View File

@ -117,7 +117,7 @@ class NonCouponAbleRule extends Discount
if (count($endRules) == 1) {
$this->save(array_first($endRules)['rule']);
return $endRules;
return array_first($endRules)['impact'];
}
$maxImpact = 0;