X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Related products: with thb. + N column format + add to cart button. (https://forum.x-cart.com/showthread.php?t=43179)

Yurij 10-23-2008 12:40 AM

Related products: with thb. + N column format + add to cart button.
 
2 Attachment(s)
UPDATE 24-10-2008,
UPDATE 29-10-2008
(sql code)
UPDATE 22-01-2009 (sql code for xcart 4.1.9)

Little mode for Related Product on the detail product page:
a) a "PRODUCT THUMBNAIL PHOTO", will appear in related products
b) they can specify "HOW MANY PRODUCTS, WILL APPEAR" in related products (you can specify this option in the admin area)
c) allow for the "BUY NOW" BUTTON, to appear in related products (you can specify this option in the admin area)

---------------------------------

0. Backup mysql


1. Apply mysql patch:

Code:

insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '', '');
insert into xcart_config VALUES ('related_num_column', 'Display related products list in multiple columns (leave empty to use standard format)', '3', 'Appearance', '5', 'text', '', '', '');
insert into xcart_config VALUES ('related_add_to_cart', 'Enable add to cart button for related products', 'N', 'Appearance', '6', 'checkbox', 'N', '', '');



for version x-cart 4.1.9:

Code:

insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '');
insert into xcart_config VALUES ('related_num_column', 'Display related products list in multiple columns (leave empty to use standard format)', '3', 'Appearance', '5', 'text', '', '');
insert into xcart_config VALUES ('related_add_to_cart', 'Enable add to cart button for related products', 'N', 'Appearance', '6', 'checkbox', 'N', '');



2. Change file code for "skin1/modules/Upselling_Products/related_products.tpl"

PHP Code:

{* $Idrelated_products.tpl,v 1.15.2.1 2007/05/02 06:05:39 max Exp $ *}

{if 
$product_links ne ""}

{if 
$config.Appearance.related_num_column lte 0}
{
capture name=dialog}
<
table cellspacing="5">
{
section name=cat_num loop=$product_links}
<
tr class="ItemsList">
    <
td width="1%">#{$product_links[cat_num].productid}</td>
    
<td width="99%"><a href="product.php?productid={$product_links[cat_num].productid}"{if $config.Upselling_Products.upselling_new_window eq 'Y'target="_blank"{/if} class="ItemsList">{$product_links[cat_num].product|amp}</a></td>
</
tr>
{/
section}
</
table>
{/
capture}
{include 
file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra='width="100%"'}

{else}

{
capture name=dialog}

{
assign var="count_per_row" value=`$config.Appearance.related_num_column`}

{
math equation="floor(100/x)" x=$count_per_row assign="width"}
{
assign var="count" value=0}

<
table width="100%">
{
section loop=$product_links name=proid}
        {if 
$count is div by $count_per_row}
            <
tr>
            {
assign var="count" value=0}
        {/if}

        <
td width="{$width}%" height="100%" align="center" valign="top" >

            <
a href="product.php?productid={$product_links[proid].productid}class="ItemsList">{$product_links[proid].product}</a><br />
            <
a href="product.php?productid={$product_links[proid].productid}"{if $config.Modules.upselling_new_window eq 'Y'target="_blank"{/if}>
                {include 
file="product_thumbnail.tpl" productid=$product_links[proid].productid image_x=$config.Appearance.thumbnail_width tmbn_url=$product_links[proid].tmbn_url}
            </
a>
            <
br />
            <
font class="ProductPrice">{$lng.lbl_our_price}: {include file="currency.tpl" value=$product_links[proid].taxed_price}</font>
            <
br /><br />
            {if 
$config.Appearance.related_add_to_cart eq "Y"}
                {if 
$config.General.unlimited_products eq "Y" || $product_links[proid].avail gt 0}
                    {include 
file="buttons/button.tpl" style="button" button_title=$lng.lbl_add_to_cart href="javascript: self.location='cart.php?mode=add&productid=`$product_links[proid].productid`&amount=1'"}
                {else}
                    <
b>{$lng.txt_out_of_stock}</b>
                {/if}
            {/if}
        </
td>

        {
capture name=prod_index}
            {
math equation="index+x+1" index=$count x=$count_per_row}
        {/
capture}
        
        {if 
$smarty.capture.prod_index is div by $count_per_row}
            </
tr>
            <
tr>
                <
td colspan="{$count_per_row}"><hr></td>
            </
tr>
        {/if}
        {
math equation="x+1" x=$count assign="count" }

{/
section}
{if 
$count lt $count_per_row}
{
section name=rest_cells loop=$count_per_row start=$count}
    <
td class="SectionBox">&nbsp;</td>
{/
section}
{/if}
</
tr>
</
table>

{/
capture}
{include 
file="dialog.tpl" title=$lng.lbl_related_products content=$smarty.capture.dialog extra='width="100%"'}

{/if}
{/if} 



PS. Tested for xcart 4.1.9 - 4.1.11.
PS2. I would be grateful for any comments on that decision.

Product details page:
Attachment 1190

Admin area:
Attachment 1191

Asiaplay 10-23-2008 08:50 PM

Re: Related products: with thb. + N column format + add to cart button.
 
Smile... abbreviations in your thread title make it hard to read... it took me a few seconds to translate and see what you have done... but is great

Is cool you pass this finished RELATED PRODUCTS mod...
- so people can have their "Related Products" appear as:-
a) a "PRODUCT THUMBNAIL PHOTO", will appear in related products
b) they can specify "HOW MANY PRODUCTS, WILL APPEAR" in related products
c) allow for the "BUY NOW" BUTTON, to appear in related products

This is a great little mod, as I see lots of sites with boring "list of related products" - a list I personally thinks adds nothing (PHOTOS like in your mod achieves is just so much better!!!).

Great little mod Yurij and I am sure many forum members will benefit from it... :)
Your team is a great addition to the forum and does offer very useful coding advice.

Cheers - Asiaplay

Yurij 10-24-2008 04:27 AM

Re: Related products: with thb. + N column format + add to cart button.
 
Quote:

Originally Posted by Asiaplay
Smile... abbreviations in your thread title make it hard to read... it took me a few seconds to translate and see what you have done... but is great

Is cool you pass this finished RELATED PRODUCTS mod...
- so people can have their "Related Products" appear as:-
a) a "PRODUCT THUMBNAIL PHOTO", will appear in related products
b) they can specify "HOW MANY PRODUCTS, WILL APPEAR" in related products
c) allow for the "BUY NOW" BUTTON, to appear in related products

This is a great little mod, as I see lots of sites with boring "list of related products" - a list I personally thinks adds nothing (PHOTOS like in your mod achieves is just so much better!!!).

Great little mod Yurij and I am sure many forum members will benefit from it... :)
Your team is a great addition to the forum and does offer very useful coding advice.

Cheers - Asiaplay


Thank you for message.
I used it for description this modification. )))

Yesterday i did not have time to write a description.

Asiaplay 10-24-2008 04:50 AM

Re: Related products: with thb. + N column format + add to cart button.
 
No problem Yurji - know you are busy... your mod is cool (no surprises here, as can see you know x-cart code inside out)... so I just wanted to make sure, that new members understood what it does... as it is a useful mod, but also an easy one for everyone to implement if they want to...

All the best and cheers - Asiaplay

bluecat 10-24-2008 02:14 PM

Re: Related products: with thb. + N column format + add to cart button.
 
Works great here, thank you. However, if I leave the number blank (under: Display related products list in multiple columns (leave empty to use standard format): it reverts back to 3 or the previous number entered. Is there a way to make these line up vertically with a partial description?

Thank you

Yurij 10-29-2008 12:38 AM

Re: Related products: with thb. + N column format + add to cart button.
 
Quote:

Originally Posted by bluecat
Works great here, thank you. However, if I leave the number blank (under: Display related products list in multiple columns (leave empty to use standard format): it reverts back to 3 or the previous number entered. Is there a way to make these line up vertically with a partial description?

Thank you


Yes. Try apply next mysql query:

PHP Code:

update  xcart_config set defvalue='' where name 'related_num_column'


ChristineP 01-13-2009 11:22 AM

Re: Related products: with thb. + N column format + add to cart button.
 
Kudos Yurji, Great job!

Awesome mod.

Thank you,
Christine

fmoses 01-21-2009 09:12 PM

Re: Related products: with thb. + N column format + add to cart button.
 
1 Attachment(s)
I'm trying to install it on version 4.1.9 and got the follwing error when trying to apply patch

SQL PATCH FAILED AT QUERY:
insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '', '')

Yurij 01-22-2009 05:05 AM

Re: Related products: with thb. + N column format + add to cart button.
 
Quote:

Originally Posted by fmoses
I'm trying to install it on version 4.1.9 and got the follwing error when trying to apply patch

SQL PATCH FAILED AT QUERY:
insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '', '')




For version 4.1.9 use next MYSQL patch:
PHP Code:

insert into xcart_config VALUES ('sep001''Related product''''Appearance''4''separator''''');
insert into xcart_config VALUES ('related_num_column''Display related products list in multiple columns (leave empty to use standard format)''3''Appearance''5''text''''');
insert into xcart_config VALUES ('related_add_to_cart''Enable add to cart button for related products''N''Appearance''6''checkbox''N'''); 


PS. I have not tested on version below 4.1.11 (in 4.1.9 I think should work). If this does not work, I try to fix it later (for old version).

ChristineP 01-22-2009 05:11 AM

Re: Related products: with thb. + N column format + add to cart button.
 
I had the same error, though it was a quick fix as I realized I needed to make sure I had the correct fields in MYSQL database on our server. I also verified within my name field other instances of sep--, so I knew our database was on par with his query. Yurij's query is to update 9 fields in his database, but for my database I had only 8 fields. So I needed to remove one field from his query and it worked.

First verify in your MYSQL database the number of fields you have and that will determine the query string. For those who need help with understanding query structure: insert into xcart_config is inserting new data into the xcart_config table, then VALUES ('', '', '', '', '', '', '', ''); is indicating the query string to apply a value where each field is separated by single quote as 'field value name here' or '' (the '' will pass through without applying new information to that field). Here's how my query read:

insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '');
insert into xcart_config VALUES ('related_num_column', 'Display related products list in multiple columns (leave empty to use standard format)', '3', 'Appearance', '5', 'text', '', '');
insert into xcart_config VALUES ('related_add_to_cart', 'Enable add to cart button for related products', 'N', 'Appearance', '6', 'checkbox', 'N', '');

Christine

Quote:

Originally Posted by fmoses
I'm trying to install it on version 4.1.9 and got the follwing error when trying to apply patch

SQL PATCH FAILED AT QUERY:
insert into xcart_config VALUES ('sep001', 'Related product', '', 'Appearance', '4', 'separator', '', '', '')



All times are GMT -8. The time now is 03:54 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.