A-Z Hosting Posted April 28, 2015 Share Posted April 28, 2015 What is the best way to remove free products $0.00 from my bestsellers array? $best_sellers Has anybody ever tried to do this? Can a smarty reiteration be used in the .tpl file and parse through the array adding those without a price greater than $0.01 to $newbestsellers? I was just getting ready to tackle this using smarty logic, but decided I would ask her first in case it's been done before. 1.6.0.14 {include file="$tpl_dir./product-list.tpl" products=$best_sellers class='blockbestsellers tab-pane' id='blockbestsellers' active=$active_ul} Wil Link to comment Share on other sites More sharing options...
A-Z Hosting Posted April 28, 2015 Author Share Posted April 28, 2015 {foreach from=$best_sellers key=key item=value} {if $value.price == '$0.00'} {$best_sellers[$key]=null} {/if} {/foreach} {$new_best_sellers = array_values($best_sellers)} {include file="$tpl_dir./product-list.tpl" products=$new_best_sellers class='blockbestsellers tab-pane' id='blockbestsellers' active=$active_ul} Unfortunately {$best_sellers[$key]=null} only leaves me with a dead broken product because the key itself isn't removed. Smarty doesn't seem to have an "unset()" function of any kind. Other ideas? Array ( [0] => [1] => [2] => Array ( [id_product] => 541 [id_product_attribute] => 49 [link_rewrite] => rose-01 [name] => Rose 01 [description_short] => Rose 01... [id_category_default] => 43 [id_image] => 541-601 [legend] => [sales] => 1 ---snipp----- Link to comment Share on other sites More sharing options...
A-Z Hosting Posted May 6, 2015 Author Share Posted May 6, 2015 Nobody has any idea on this one? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now