| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
3 column layout with thumbnail for Related Products | ||||
|
|
Thread Tools | Search this Thread |
#31
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
ps I'd love to know how to add the "Add to cart" button to this to make it work. I've had a brief go but I can't get it work by substituting in "$product_links[cat_num].product" in:
{include file="buttons/buy_now.tpl" style="button" href="javascript: document.orderform_`$product.productid`_`$product. add_date`.submit();"} which I took from product_box.tpl.
__________________
X-Cart Gold Version 4.3.2 |
|||||||
#32
|
|||||||||
|
|||||||||
Re: 3 column layout with thumbnail for Related Products
Quote:
How can I limit the number of items shown? For instance, lets say I want a maximum of 3 items shown, but I have 6 related products, some of which may be out of stock at times and I don't want listed then, but I want them listed instead of other items on the list if they are in stock. Is there a way to only have it "loop" a certain number of times, and how would I go about doing that? Thanks.
__________________
Two Separate X-Cart Stores Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series. Integrated with Stone Edge Order Manager + POS Version 4.1.12 Gold (fresh install) - X-AOM - Linux Mods - XCSEO free |
|||||||||
#33
|
|||||||||
|
|||||||||
Re: 3 column layout with thumbnail for Related Products
Quote:
I know this is kind of late, but I just ran across this thread and figured if this didn't help you, it might help others. {section} requires a name= and a loop= There are a few more attributes that can be used though. The one you are looking for is max= Example: Code:
This will stop the loop at 3 instances returned. More reading about {section}
__________________
x-cart 4.0.13 and 4.1.7 and 4.1.10 |
|||||||||
#34
|
|||||||||
|
|||||||||
Re: 3 column layout with thumbnail for Related Products
Thanks! It took a little experimentation but I found it works fine if you put the "{section name=cat_num loop=$product_links max=3}" in the second loop.
__________________
Two Separate X-Cart Stores Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series. Integrated with Stone Edge Order Manager + POS Version 4.1.12 Gold (fresh install) - X-AOM - Linux Mods - XCSEO free |
|||||||||
#35
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
I used Sisoms code in my related_products.tpl but instead of a price I get a $ symbol under each thumbnail. How do I get a price to show up. I'm using 4.1.8 Thanks
P.S. Anyone get the buy now button?
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3 mods: reCaptcha running on UNIX www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2 mods: reCaptcha cdseo pro running on UNIX |
|||||||
#36
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
Hi Keystone, I don't know if my code will work in 4.1.8 (I have 4.1.0) but here's what I'm using: some of it won't apply (the divs) because I'm using some CSS to create round cornered boxes for the background, but the rest of the code gives me the product thumbnail, the product title, and the price in pounds.
Here it is, just take what you want! {* $Id: related_products.tpl,v 1.15 2005/12/07 14:07:32 max Exp $ *} {if $product_links ne ""} {capture name=dialog} {assign var="tmp" value="0"} {section name=cat_num loop=$product_links} {if $product_links[cat_num].productid}{assign var="tmp" value="1"}{/if} {/section} {section name=cat_num loop=$product_links} { if %cat_num.first% } <table border="0" cellspacing="0" width="100%"> <tr> {/if} {if $smarty.section.cat_num.index is div by 3} </tr><tr> {/if} <td align="center"> <div class="relatedsidebox"> <div class="relatedboxhead"><p> </p></div> <div class="relatedboxbody"> <a style="text-decoration: none;" href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_x=$config.Appearance.thumbnail_width product=$product_links[cat_num].product type="T"}</a> <br> <a style="color: #FFFFFF" href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> <b>{ $product_links[cat_num].product}</b> </a> <br> <font class="ProductPriceRelated">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font> {if $product.taxes}<font class="ProductPriceVatRelated"> {include file="customer/main/taxed_price.tpl" taxes=$product.taxes}</font> {/if} </div> </div> </td> { if %cat_num.last% } </tr></table> {/if} {/section} {/capture} {include file="dialog.tpl" title="Related products" content=$smarty.capture.dialog extra="width=100%"} {/if} I'm afraid I don't know how to put the Buy Now button in there, but personally I don't think it's necessary, as there is only a thumbnail and title, most customers are going to want to see the full product page before using Buy Now. (Well, I would at least!)
__________________
X-Cart Gold Version 4.3.2 |
|||||||
#37
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
Good point on the buy now button. I have your code in there without the div's. I have my currency set to dollars as I am in the U.S. I still am not sure why it isn't pulling the price in and only the currency symbol. Any ideas, I'm pretty new to smarty and php. I can find my way around ok and basically know what things mean but I'm not sure what I can and cannot change yet. Which part of
<font class="ProductPrice">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font> {if $product.taxes}<font class="ProductPriceVat"> {include file="customer/main/taxed_price.tpl" taxes=$product.taxes}</font> actually pulls in the price value?
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3 mods: reCaptcha running on UNIX www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2 mods: reCaptcha cdseo pro running on UNIX |
|||||||
#38
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
I think the part that actually pulls the price is this bit:
{if $product.taxes}<font class="ProductPriceVat"> {include file="customer/main/taxed_price.tpl" taxes=$product.taxes}</font> It's the taxed_price.tpl file, which is this little gem of architecture: {* $Id: taxed_price.tpl,v 1.10 2005/11/17 06:55:38 max Exp $ *} {if $taxes} {foreach key=tax_name item=tax from=$taxes} {if $tax.tax_value gt 0 or $tax.tax_value eq ""} {if $tax.display_including_tax eq "Y"} {if $display_info eq ""}{assign var="display_info" value=$tax.display_info}{/if} {$lng.lbl_including_tax|substitute:"tax":$tax.tax_ display_name}{if $display_info eq "V" or ($display_info eq "A" and $tax.rate_type eq "$")} {if $is_subtax ne 'Y'}<span id="tax_{$tax.taxid}">{/if}<b>{include file="currency.tpl" value=$tax.tax_value}</b>{if $is_subtax ne 'Y'}</span>{/if}{elseif $display_info eq "R"} {if $tax.rate_type eq "$"}{include file="currency.tpl" value=$tax.rate_value}{else}{$tax.rate_value|forma tprice}%{/if}{elseif $display_info eq "A"} {if $tax.rate_type eq "%"}{$tax.rate_value|formatprice}% ({if $is_subtax ne 'Y'}<span id="tax_{$tax.taxid}">{/if}{include file="currency.tpl" value=$tax.tax_value}{if $is_subtax ne 'Y'}</span>{/if}){/if}{/if} {* <br /> *} {/if} {/if} {/foreach} {/if} It's not as bad as it looks though, basically it's lots of {if} tags, which then decide what to display, depending on whether you've selected to display prices including tax, etc. I would comment out the first part (not in the taxed_price.tpl file, in the related_products.tpl file) {* <font class="ProductPrice">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font> *} and leave this part (below), and see what you get. {if $product.taxes}<font class="ProductPriceVat"> {include file="customer/main/taxed_price.tpl" taxes=$product.taxes}</font> Then do this: {if $product.taxes}<font class="ProductPriceVat">TEST TEST TEST {include file="customer/main/taxed_price.tpl" taxes=$product.taxes}</font> to see if the words "TEST TEST TEST" display. If they do, you know that the rest of the code is creating (or trying to create!) the text after the TEST words. That's how I find out lots of things when editing the appearance of my cart - very often I'm not sure which piece of code is producing what, so I just bung in "TEST TEST TEST" somewhere in the template I'm editing, and see where it turns up. So basically just feel free to comment out anything you want using {* *}, then you can see what code is doing what, without any risk of mucking the template up. You just delete the {* *} comment tags when you want to bring that piece of code back into action. Let me know how you get on.
__________________
X-Cart Gold Version 4.3.2 |
|||||||
#39
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
I did what you said and the TEST check did not show up at all so I think the {if $product.taxes} statement is the issue. Not sure what to do from here.
Here is the code I have now: {* $Id: related_products.tpl,v 1.15.2.1 2007/05/02 06:05:39 max Exp $ *} {if $product_links ne ""} {capture name=dialog} {assign var="tmp" value="0"} {section name=cat_num loop=$product_links} {if $product_links[cat_num].productid}{assign var="tmp" value="1"}{/if} {/section} {section name=cat_num loop=$product_links} { if %cat_num.first% } <table border="0" cellspacing="0" width="100%"> {/if} {if $smarty.section.cat_num.index is div by 3} </tr><tr> <tr> <td><img src="{$ImagesDir}/spacer.gif"></td> </tr> <tr valign="top"> {/if} <td width="33%" align="center"> <a style="text-decoration: none;" href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> {include file="product_thumbnail.tpl" productid=$product_links[cat_num].productid image_x=$config.Appearance.thumbnail_width product=$product_links[cat_num].product tmbn_url=$product_links[cat_num].tmbn_url}</a> <br> <a href="product.php?productid={ $product_links[cat_num].productid }"{if $config.Modules.upselling_new_window eq 'Y'} target="_blank"{/if}> <b>{ $product_links[cat_num].product}</b> </a> <br> {* <font class="ProductPrice">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font> *} {if $product.taxes} {include file="customer/main/taxed_price.tpl" taxes=$product.taxes} {/if} </td> { if %cat_num.last% } </tr></table> {/if} {/section} {/capture} {include file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra='width="100%"'} {/if}
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3 mods: reCaptcha running on UNIX www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2 mods: reCaptcha cdseo pro running on UNIX |
|||||||
#40
|
|||||||
|
|||||||
Re: 3 column layout with thumbnail for Related Products
Well, from that we can deduce that the second part isn't producing anything at all on screen, so it must be the first part which produces the dollar sign:
<font class="ProductPrice">{include file="currency.tpl" value=$product_links[cat_num].taxed_price}</font> The value of the price comes from $product_links[cat_num].taxed_price and this is fed into currency.tpl, which produces the dollar sign (presumably). I'm not too sure how exactly $product_links[cat_num].taxed_price pulls the product price through, but somebody else here is sure to have much more experience than I with this - can anybody else help?
__________________
X-Cart Gold Version 4.3.2 |
|||||||
|
|||
X-Cart forums © 2001-2020
|