Created
December 19, 2023 08:36
-
-
Save danielborzov/2f08da21adf2f283441d91071c19078f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/functions/fn.cart.php b/app/functions/fn.cart.php | |
index 214e2966bc..3dac411f66 100644 | |
--- a/app/functions/fn.cart.php | |
+++ b/app/functions/fn.cart.php | |
@@ -178,6 +178,7 @@ function fn_get_cart_product_data($hash, &$product, $skip_promotion, &$cart, &$a | |
) | |
) { | |
fn_delete_cart_product($cart, $hash); | |
+ $cart['save_cart_content'] = true; | |
return false; | |
} | |
@@ -193,7 +194,11 @@ function fn_get_cart_product_data($hash, &$product, $skip_promotion, &$cart, &$a | |
$amount = !empty($product['amount_total']) ? $product['amount_total'] : $product['amount']; | |
$_pdata['price'] = fn_get_product_price($product['product_id'], $amount, $auth); | |
- $_pdata['base_price'] = (isset($product['stored_price']) && $product['stored_price'] == 'Y') ? $product['price'] : $_pdata['price']; | |
+ if (isset($product['stored_price']) && YesNo::toBool($product['stored_price'])) { | |
+ $_pdata['base_price'] = $product['price']; | |
+ } else { | |
+ $_pdata['base_price'] = $_pdata['price']; | |
+ } | |
/** | |
* Executes after getting product data from database. | |
@@ -280,9 +285,15 @@ function fn_get_cart_product_data($hash, &$product, $skip_promotion, &$cart, &$a | |
} | |
} | |
- $product['price'] = ($_pdata['zero_price_action'] == 'A' && isset($product['custom_user_price'])) | |
- ? $product['custom_user_price'] | |
- : floatval($_pdata['price']); | |
+ if ( | |
+ $_pdata['zero_price_action'] === ProductZeroPriceActions::ASK_TO_ENTER_PRICE | |
+ && $_pdata['price'] <= 0 | |
+ && isset($product['custom_user_price']) | |
+ ) { | |
+ $product['price'] = $product['custom_user_price']; | |
+ } else { | |
+ $product['price'] = (float) $_pdata['price']; | |
+ } | |
$cart['products'][$hash]['price'] = $product['price']; | |
@@ -304,6 +315,20 @@ function fn_get_cart_product_data($hash, &$product, $skip_promotion, &$cart, &$a | |
$_pdata['amount'] = $product['amount']; | |
$_pdata['price'] = $_pdata['original_price'] = fn_format_price($product['price']); | |
+ if ($_pdata['price'] <= 0 && $_pdata['zero_price_action'] === ProductZeroPriceActions::NOT_ALLOW_ADD_TO_CART) { | |
+ fn_set_notification( | |
+ NotificationSeverity::WARNING, | |
+ __('warning'), | |
+ __('zero_price_product_was_deleted', [ | |
+ '[product]' => $_pdata['product'] | |
+ ]) | |
+ ); | |
+ fn_delete_cart_product($cart, $hash); | |
+ $cart['save_cart_content'] = true; | |
+ | |
+ return false; | |
+ } | |
+ | |
$_pdata['stored_price'] = $product['stored_price']; | |
if ($cart['options_style'] == 'F') { | |
@@ -4642,6 +4667,11 @@ function fn_calculate_cart_content( | |
$cart['location_hash'] = fn_checkout_get_location_hash($cart['user_data']); | |
} | |
+ if (!empty($cart['save_cart_content'])) { | |
+ fn_save_cart_content($cart, $auth['user_id']); | |
+ unset($cart['save_cart_content']); | |
+ } | |
+ | |
/** | |
* Processes cart data after calculating all prices and other data (taxes, shippings etc) including products group | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/var/langs/en/core.po b/var/langs/en/core.po | |
index caea4098e1..2d42becad2 100644 | |
--- a/var/langs/en/core.po | |
+++ b/var/langs/en/core.po | |
@@ -7980,6 +7980,10 @@ msgctxt "Languages::product_options_forbidden_combination" | |
msgid "The <strong>[product]</strong> product has options that are included in the forbidden combination. The product was deleted from the cart" | |
msgstr "The <strong>[product]</strong> product has options that are included in the forbidden combination. The product was deleted from the cart" | |
+msgctxt "Languages::zero_price_product_was_deleted" | |
+msgid "The <strong>[product]</strong> product has zero price. The product was deleted from the cart" | |
+msgstr "The <strong>[product]</strong> product has zero price. The product was deleted from the cart" | |
+ | |
msgctxt "Languages::product_disabled_options" | |
msgid "The product <strong>[product]</strong> has options or option variants that are not available anymore, so it was removed from cart" | |
msgstr "The product <strong>[product]</strong> has options or option variants that are not available anymore, so it was removed from cart" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment