Jump to content

Can´t use same variable at another page (I´m noob)


ccagomes

Recommended Posts

HiI, 'm not an expert. I'll get right to the point. Please help me if possible  :sweat:

 

There is a "prod_weight_class" variable that is displayed below the price when the person views the product. I would like this variable to also appear next to the price in the search results in the thumbnails, I already tried adding it 10x possible ways like I did in other pages and got success, but it did not work out there. IS IT POSSIBLE?

 

Below the picture and files of the product page, where it appears, and the search results file where I wanted it to appear. THANK YOU!!!!!!
 
Details:
Product View Page: public_html/application/views/products/view.php
 
Search Results Page: public_html/application/views/common/json/product_thumb_template.php
 
post-205913-0-18321100-1508566116_thumb.jpg

product_thumb_template .php

view.php

Link to comment
Share on other sites

FYI, it's rather difficult for people to download files and scan through them trying to find the right place to look for code. Can you show the relevant parts? For page that shows the product, the important part is where the prod_weight_class comes from (where and how it gets set), and on the search page we'd need to know how the search result data is generated.

 

Variables on one page aren't available on other pages, because they're entirely separate. So what you have to do is see where the value comes from where it works, then replicate that sort of behavior on the search page. For example, if the value comes from the database then you'd need to modify the search page so that its database query makes sure to return that same value and so it can be used when displaying the results.

Link to comment
Share on other sites

FYI, it's rather difficult for people to download files and scan through them trying to find the right place to look for code. Can you show the relevant parts? For page that shows the product, the important part is where the prod_weight_class comes from (where and how it gets set), and on the search page we'd need to know how the search result data is generated.

 

Variables on one page aren't available on other pages, because they're entirely separate. So what you have to do is see where the value comes from where it works, then replicate that sort of behavior on the search page. For example, if the value comes from the database then you'd need to modify the search page so that its database query makes sure to return that same value and so it can be used when displaying the results.

 

Thank you @requinix. About what you said in paragraph 2, that's the point I do not have much knowledge about how to make the other page understand. When I paste the $product_info["prod_weight_class"] in any place of view.php I can see the result. At product creation page I set the value for "prod_weight_class", I just moving the variable inside the view.php to see the information in a different place on the same page.

 

Theres a way that I can ask the other page to get the variable from view.php ?

 

Below the part where I place the code at product view and is working. Thank you again.

 

**************************** (view.php)

 

          <div class="pro-description">
             
            <div class="in-border">
               <? if ($product_info['prod_stock']<1):?>
               <div class="out-stock-text">
                <span class="txt"><?php echo Utilities::getLabel('M_Out_of_Stock')?></span>
           </div>
              <?php endif;?>
              <div class="upper clearfix">
               <span itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                <meta itemprop="priceCurrency" content="<?php echo Settings::getSetting("CONF_CURRENCY");?>" />                 
               <?php  $price=$product_info['prod_sale_price'];?>
               <?php if ($product_info['special']) { ?>
                <div class="price-side"><?php echo Utilities::getLabel('L_Original_Price') ?>: 
                <span class="striked" ><?php echo Utilities::displayMoneyFormat($price,true,true,Settings::getSetting("CONF_DISP_INC_TAX")); ?></span> 
                <span class="actuall-price" itemprop="price" ><?php echo Utilities::displayMoneyFormat($product_info['special'],true,true,Settings::getSetting("CONF_DISP_INC_TAX")); ?> </span>    <?php echo $product_info["prod_weight_class"]</span>' ?>
 
****************************
 
 
And I´m trying to see tha value here too:
 
{{#products}}
<div data-attr-id="{{promotion_id}}"
     class="{{#prod_promotion_id}}thumb_impression  thumb_click {{/prod_promotion_id}} shop-item {{#prod_out_of_stock}} <?php echo 'out-of-stock'; ?> {{/prod_out_of_stock}}"
...
    {{#prod_sale_price}}
    <div class="price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        {{#special}}
        <span class="price-new" itemprop="price">{{prod_special}}</span> <span class="price-old">{{prod_price}}</span>    "Here"
        {{/special}}
        {{^special}}
        <span class="price-new" itemprop="price">{{prod_price}}</span>
        {{/special}}
    </div>
    {{/prod_sale_price}}

Link to comment
Share on other sites

In the first part, the prod_weight_class value is in the $product_info variable. What is the code involved in creating that?

 

In the second part, presumably you'll be using a {{prod_weight_class}} placeholder like you're doing with the others. Where are {{promotion_id}} and {{prod_sale_price}} and such coming from?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.