Skip to content

Commit 2ea036c

Browse files
committed
Fix issue of weight not changing on product block when variations changed
1 parent 2658dca commit 2ea036c

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

blocks/community_product/view.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ $(function () {
9393
}
9494
}
9595

96+
if (variation['weight']) {
97+
let weightHolder = pdb.find('.store-product-weight-value');
98+
if (weightHolder) {
99+
$(weightHolder).html(variation['weight']);
100+
}
101+
}
102+
96103
var quantityField = pdb.find('.store-product-qty');
97104
if (variation['maxCart'] !== false) {
98105
quantityField.prop('max', variation['maxCart']);

blocks/community_product/view.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ class="store-product-price"
269269
?>
270270
<div class="store-product-weight">
271271
<strong><?= t("Weight") ?>:</strong>
272-
<?= $product->getWeight() ?>
272+
<span class="store-product-weight-value"><?= $product->getWeight() ?></span>
273273
<?= $config->get('community_store.weightUnit') ?>
274274
</div>
275275
<?php
@@ -689,6 +689,7 @@ class="img-responsive img-fluid"
689689
'imageThumb' => $thumb ? $thumb->src : '',
690690
'image' => $imgObj ? $imgObj->getRelativePath() : '',
691691
'sku' => $variation->getVariationSKU(),
692+
'weight' => $variation->getVariationWeight(),
692693
'saleTemplate'=> t('On Sale') .': <span class="store-sale-price"></span>&nbsp;' . t('was') . '&nbsp;<span class="store-original-price"></span>'
693694
];
694695
if ($isWholesale) {

src/CommunityStore/Product/ProductVariation/ProductVariation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public function setVariationLength($pvLength)
409409

410410
public function getVariationWeight()
411411
{
412-
return $this->pvWeight;
412+
return $this->pvWeight + 0;
413413
}
414414

415415
public function setVariationWeight($pvWeight)

0 commit comments

Comments
 (0)