Jump to content
Sign in to follow this  
mnk

Вывод веса на странице товара

Recommended Posts

vQmod для дефолтного шаблона.

 

Выводит вес товара на странице товара в виде: [число без лишних нулей после десятичного знака] [пробел] [единица веса] 

 

Например,

Вес: 100 г

Вес: 5,47 кг

Вес: 7,1 кг

 

Если вес=0 - соответственно, ничего не выводится.

 

weight-public.xml

Share this post


Link to post
Share on other sites
<file name="catalog/controller/product/product.php">
        <operation>
            <search position="after">
            <![CDATA[$this->data['text_model'] = $this->language->get('text_model');]]>
            </search>
            <add>
            <![CDATA[$this->data['text_weight'] = $this->language->get('text_weight');]]>
            </add>
        </operation>
        <operation>
            <search position="after">
            <![CDATA[$this->data['review_status'] = $this->config->get('config_review_status');]]>
            </search>
            <add>
            <![CDATA[
            if ($product_info['weight'] > 0) {$this->data['weight'] = $this->weight->format($product_info['weight'], $product_info['weight_class_id']); }
            ]]>
            </add>
        </operation>
    </file>
       <file name="catalog/language/russian/product/product.php">
    <operation error="skip">
        <search position="after"><![CDATA[$_['text_error']        = 'Товар не найден!';]]></search>
        <add><![CDATA[
        $_['text_weight']       = 'Вес:';
        ]]></add>
    </operation>
    </file>
        <file name="catalog/language/english/product/product.php">
    <operation error="skip">
        <search position="after"><![CDATA[$_['text_error']        = 'Product not found!';]]></search>
        <add><![CDATA[
        $_['text_weight']       = 'Weight:';
        ]]></add>
    </operation>
</file>

    <file name="catalog/view/theme/*/template/product/product.tpl">
        <operation>
            <search position="before">
            <![CDATA[<?php if ($reward) { ?>]]>
            </search>
            <add>
            <![CDATA[
            <?php if (isset($weight)) { ?>   <span><?php echo $text_weight; ?>
</span><td class="description-right"><?php echo (float)$weight.  
           preg_replace("/[0-9]./", " ", $weight);?><br /><?php } ?>
            ]]>
            </add>
        </operation>
    </file>
</modification>

Хотелось бы узнать мнение специалистов .... правильности изменения кода.

 

ps mnk спасибо!

 

Вопрос, а как вывести данные из фильтра в карточку товара, если есть значения у товара?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.