Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not reset customization in FO when changing combination (178x) #29635

Merged
merged 6 commits into from Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions controllers/front/ProductController.php
Expand Up @@ -481,6 +481,7 @@ public function displayAjaxRefresh()
'product_minimal_quantity' => $minimalProductQuantity,
'product_has_combinations' => !empty($this->combinations),
'id_product_attribute' => $product['id_product_attribute'],
'id_customization' => $product['id_customization'],
'product_title' => $this->getProductPageTitle(
$this->getTemplateVarPage()['meta'] ?? []
),
Expand Down
3 changes: 2 additions & 1 deletion src/Adapter/Cart/QueryHandler/GetCartForViewingHandler.php
Expand Up @@ -221,7 +221,8 @@ private function prepareProductForView(array $products, Currency $currency, int
'unit_price' => $product['product_price'],
'total_price_formatted' => $this->locale->formatPrice($product['product_total'], $currency->iso_code),
'unit_price_formatted' => $this->locale->formatPrice($product['product_price'], $currency->iso_code),
'image' => $this->imageManager->getThumbnailForListing($image['id_image']),
// it is possible that there is no image for product, so we don't show anything, but at least avoid breaking whole page
'image' => isset($image['id_image']) ? $this->imageManager->getThumbnailForListing($image['id_image']) : '',
];

if (isset($product['customizationQuantityTotal'])) {
Expand Down
12 changes: 11 additions & 1 deletion themes/_core/js/product.js
Expand Up @@ -228,7 +228,17 @@ function updateProduct(event, eventType, updateUrl) {
$(prestashop.selectors.product.customization)
.first()
.replaceWith(data.product_customization);
$(prestashop.selectors.product.inputCustomization).val(0);

// refill customizationId input value when updating quantity or combination
if (
(eventType === 'updatedProductQuantity' || eventType === 'updatedProductCombination')
&& data.id_customization
) {
$(prestashop.selectors.cart.productCustomizationId).val(data.id_customization);
} else {
$(prestashop.selectors.product.inputCustomization).val(0);
}

$(prestashop.selectors.product.variantsUpdate)
.first()
.replaceWith(data.product_variants);
Expand Down