Jump to content

[MOD] Display the declinated weight on product page


spice_prods

Recommended Posts

Display the declinated weight on product page

 

 

1/ changes in "product.php" :

 

 

add :

    'weightUnit' => Configuration::get('PS_WEIGHT_UNIT'),

 

after :

    'outOfStockAllowed' => intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')),

 

 

 

add :

                $combinations[$row['id_product_attribute']]['weight'] = floatval($row['weight']);

 

after :

                $combinations[$row['id_product_attribute']]['ecotax'] = floatval($row['ecotax']);

 

 

 

2/ changes in "product.tpl" :

 

 

add :

var productWeight = '{$product->weight|escape:'htmlall':'UTF-8'}';

 

after :

var productReference = '{$product->reference|escape:'htmlall':'UTF-8'}';

 

 

 

replace :

        addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}');

 

 

by :

        addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.weight});

 

 

 

add the product's weight display where you want :

            <!-- products weight --><br/>            <p>Poids : <span id="product_weight">{$product->weight}</span> {$weightUnit}</p>

 

for example, before :

<p{if !$allow_oosp && $product->quantity == 0} style="display:none;"{/if} id="add_to_cart" class="buttons_bottom_block"><input type="submit" name="Submit" value="{l s='Add to cart'}" class="exclusive" /></p>

 

 

 

3/ changes in "product.js" :

 

 

replace :

function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference)

 

by :

function addCombination(idCombination, arrayOfIdAttributes, quantity, price, ecotax, id_image, reference, weight)

 

 

 

add :

    combination['weight'] = weight;

 

after :

    combination['reference'] = reference;

 

 

 

add :

            selectedCombination['weight'] = combinations[combination]['weight'];

 

after :

            selectedCombination['price'] = combinations[combination]['price'];

 

 

 

add :

// Calcul et affichage du poids des produits<br/>        var declined_weight = Number(selectedCombination['weight']) + Number(productWeight);<br/><br/>        if (selectedCombination['weight'])<br/>            $('#product_weight').text(declined_weight);<br/><br/>        else if (productWeight)<br/>            $('#product_weight').text(productWeight);<br/>        $('#product_weight:hidden').show('slow');<br/>

 

after :

function updateDisplay()<br/>{<br/>

Link to comment
Share on other sites

  • 7 months later...

Hi,

This is a great little mod which is just what I was looking for.

I have located the field between Reference and quantity.

Could anyone advice what I would need to add in the .product.tpl to align the weight: with the other fields please.

Image of what I mean is attached.


Here is the code in the .tpl


reference}style="display:none;"{/if}>{l s='Reference :'} {$product->reference|escape}
           <!-- products weight -->

Weight : {$product->weight} {$weightUnit} 
           <!-- quantity wanted -->

quantity == 0) || $virtual} style="display:none;"{/if}>
{l s='Quantity :'}
               <input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}1{/if}" size="2" maxlength="3" />




Edit: Solved - Just copied the code for the reference part and substituted 'reference' with weight.

43072_7Lx4Fd4H4hO0sFAMG0lq_t

Link to comment
Share on other sites

  • 2 months later...

Hi,

I found this mod very useful for my site.

I have now upgraded to 1.4.3 The product.php file is very different than with 1.3.7

Could anyone advise how to get the weight on the product page on 1.4.3 please.

Thanks.

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...
  • 3 months later...
  • 4 months later...
  • 9 months later...
  • 5 months later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...