Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Addon With Custom Database Column. Column Showing As Null When It Has Value Rate Topic   - - - - -

 
  • Jmoffat
  • Member
  • Members
  • Join Date: 15-Oct 12
  • 39 posts

Posted 18 February 2016 - 01:29 PM #1

We're currently developing an addon which adds a custom dropdown to the edit product page allowing the admin to state that a product is fresh. if the product is fresh certain shipping methods will be excluded. 

 

when the addon is installed it adds a new column to the the product information database called is_fresh. 

 

so far the dropdown on the product page works. selecting "yes" sets the value of is_fresh in the database to 1 for that product. I have then written the following script to add a "product is fresh" logo to the product page at the customer side. 

{if $product.is_fresh}
<img src="/design/themes/responsive/media/images/addons/fresh_ambient/fresh.png" style="max-width: 100px;" alt="always fresh">
{/if}

this goes into the template hook product_details_bottom.post.tpl and it works absolutely fine. 

 

The next step is to remove any shipping method unsuitable for fresh products at the checkout if there is a fresh product in the cart. For this I'm using the template hook shipping.rates.post.tpl to place my own code within the shipping section at the checkout. 

 

I'm using the following code to test.

{foreach from=$group.products item="product"}
<p>{$product.product_id|fn_get_product_name}</p>
{if $product.is_fresh}
<p>works</p>
{else}<p>doesn't work</p>
{/if}
{/foreach}

Here it will successfully post the product name for each product in the basket but it shows the text "doesn't work" under each even when the product in the basket has the "is fresh" box ticked. 

 

 

 

when you simply try to print the value of $product,is_fresh like so

{foreach from=$group.products item="product"}
{$product.is_fresh}
{/foreach}

nothing shows up at all as if the value of that column is null. 

 

Does anyone know how I can fix this? Why does it work correctly on the product page but not at the checkout? 

 

Attached Files