Skip to content

Commit 01cee3c

Browse files
Merge pull request #10277 from magento-gl/spartans_pr_10122025
[Spartans] BugFixes Delivery
2 parents b319969 + 2778590 commit 01cee3c

File tree

14 files changed

+2308
-330
lines changed

14 files changed

+2308
-330
lines changed

app/code/Magento/Checkout/view/frontend/web/js/cart/ensure-subtotal-sync.js

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ define([
1515
return function initEnsureSubtotalSync(config, element)
1616
{
1717
const $root = $(element || document);
18-
let clicked = false;
18+
19+
// Check if already synced on the body element (persists across form replacements)
20+
if ($('body').data('cart-synced')) {
21+
return;
22+
}
1923

2024
function parsePrice(text)
2125
{
@@ -44,7 +48,7 @@ define([
4448
// Sum of row totals on the table
4549
let sum = 0;
4650

47-
$root.find('#shopping-cart-table .col.subtotal .cart-price').each(function () {
51+
$root.find('#shopping-cart-table .col.subtotal .price-excluding-tax .cart-price').each(function () {
4852
const text = $(this).text(), val = parsePrice(text);
4953

5054
if (!isNaN(val)) {
@@ -70,19 +74,35 @@ define([
7074
return;
7175
}
7276

73-
if (clicked) {
74-
return;
75-
}
76-
7777
const central = getCentralSubtotal(), summary = getSummarySubtotal();
7878

7979
if (!isNaN(central) && !isNaN(summary) && central !== summary) {
80-
const $updateBtn = $root.find('.cart.main.actions button.action.update');
81-
82-
if ($updateBtn.length) {
83-
clicked = true;
84-
$updateBtn.trigger('click');
85-
}
80+
// Mark as synced immediately to prevent multiple calls
81+
$('body').data('cart-synced', true);
82+
83+
// Reload cart content via AJAX
84+
$('body').trigger('processStart');
85+
$.ajax({
86+
url: window.location.href,
87+
type: 'GET',
88+
data: { ajax: 1 },
89+
success: function (response) {
90+
// Extract and replace cart form
91+
const newContent = $(response).find('#form-validate');
92+
93+
// Replace the form with the new content
94+
$('#form-validate').replaceWith(newContent);
95+
// Reinitialize widgets on new content
96+
$('#form-validate').trigger('contentUpdated');
97+
},
98+
error: function () {
99+
$('body').trigger('processStop');
100+
$('body').data('cart-synced', false);
101+
},
102+
complete: function () {
103+
$('body').trigger('processStop');
104+
}
105+
});
86106
}
87107
}
88108

@@ -98,7 +118,7 @@ define([
98118
const obs = new MutationObserver(function () {
99119
trySync();
100120

101-
if (clicked) {
121+
if ($('body').data('cart-synced')) {
102122
obs.disconnect();
103123
}
104124
});

app/code/Magento/Quote/Model/Quote/Item/Processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function prepare(Item $item, DataObject $request, Product $candidate): vo
101101
}
102102

103103
$customPrice = $request->getCustomPrice();
104-
if (!empty($customPrice) && !$candidate->getParentProductId()) {
104+
if ($customPrice !== null && !$candidate->getParentProductId()) {
105105
$item->setCustomPrice($customPrice);
106106
$item->setOriginalCustomPrice($customPrice);
107107
}

0 commit comments

Comments
 (0)