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)
-   -   Adding Per Product Update control in basket? (https://forum.x-cart.com/showthread.php?t=20323)

Total Hosting 03-05-2006 04:51 PM

Adding Per Product Update control in basket?
 
I have seen this on several other x-cart based sites.

Is there a guide to adding an update per product, not just for the whole cart?

Also, I would like to use the small thumbnail shown on home also show in the cart.

Looking at the debugger, I see that they both pull in products_thumbnail.tpl, but looking at the template, I don't see what controls the displayed size.

Anyone?

Thanks

Total Hosting 03-05-2006 06:29 PM

My cart mods
 
Ok, both mysteries solved. For sake of the board, I'll post my hacks.

If you want to mod the cart to show the thumbnail-sized image (very handy), simply replace this at line 19 in cart.tpl
Code:

{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}
{else}
{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=$products[product].image_x image_y=$products[product].image_y product=$products[product].product tmbn_url=$products[product].tmbn_url}
{/if}

With this
Code:

{if $active_modules.Special_Offers ne "" and $products[product].have_offers}
{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}
{else}
{include file="product_thumbnail.tpl" productid=$products[product].productid image_x=$config.Appearance.thumbnail_width  product=$products[product].product tmbn_url=$products[product].tmbn_url}
{/if}

I also removed {$products[product].descr} from line 29.

I see no reason to show customers anything but the thumb, title and any options.

To add an update, per line item, you can replace the following around line 59:
Code:




{include file="buttons/delete_item.tpl" href="cart.php?mode=delete&productindex=`$products[product].cartid`"}
{if $products[product].product_options ne ''}
{if $config.UA.platform eq 'MacPPC' && $config.UA.browser eq 'MSIE'}
{include file="buttons/edit_product_options.tpl" href="javascript:window.open('`$catalogs.customer`/popup_poptions.php?target=cart&id=`$products[product].cartid`','POptions','width=400,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');" js_to_href="Y"}
{else}
{include file="buttons/edit_product_options.tpl" href="javascript:window.open('`$catalogs.customer`/popup_poptions.php?target=cart&id=`$products[product].cartid`','POptions','width=400,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');"}
{/if}
{/if}

With
Code:

<div style="padding: 8px 0px;">
{if $js_enabled}
{include file="buttons/update.tpl" type="input" href="javascript: document.cartform.submit()" js_to_href="Y"}
{/if}
{include file="buttons/delete_item.tpl" href="cart.php?mode=delete&productindex=`$products[product].cartid`"}
{if $products[product].product_options ne ''}
{if $config.UA.platform eq 'MacPPC' && $config.UA.browser eq 'MSIE'}
{include file="buttons/edit_product_options.tpl" href="javascript:window.open('`$catalogs.customer`/popup_poptions.php?target=cart&id=`$products[product].cartid`','POptions','width=400,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');" js_to_href="Y"}
{else}
{include file="buttons/edit_product_options.tpl" href="javascript:window.open('`$catalogs.customer`/popup_poptions.php?target=cart&id=`$products[product].cartid`','POptions','width=400,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');"}
{/if}
{/if}</div>

yes, there will be TWO closing DIVs in your cart.tpl with this addition.

Now, I just need to find the hacks to the button templates to replace the text with images. If anyone cares to share, that would be superb!

Hope this helps all that follow.

Total Hosting 03-05-2006 07:28 PM

Not exactly what I want, but it works for now
 
Ok, as I continue to talk to myself, here are a few more changes I made to Cart.tpl

Around line 89, I hid the update and clear cart with simple HTML Comment tags. Just in case I ever want them back, no need to remove, just hide. Then I added a "Continue Shopping" link as follows:
Code:

{if $js_enabled}
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD>{include file="buttons/button.tpl" button_title=$lng.lbl_continue style="button" href="javascript:history.go(-1)" js_to_href="Y"}
</TD>
{if $active_modules.Special_Offers}
{include file="modules/Special_Offers/customer/cart_checkout_buttons.tpl"}
{/if}
<TD align="right">
{include file="buttons/button.tpl" button_title=$lng.lbl_checkout style="button"  href="cart.php?mode=checkout"}
</TD>
</TR>
</TABLE>

This is the same way x-cart draws the Checkout button (NOTE: I also added the "Continue Shopping" label in the language file, using the variable lbl_continue and "<< Continue Shopping" just to match the "action" of the text). I also changed "Checkout" to "Checkout >>"

You can also use home.php. I chose to go with javascript:history.go(-1) for the Continue Shopping link. One nice thing about X-cart is that it uses javascript for updates and things within the cart. So history does not appear to be affected by updates and removes. So you can either send people back to the last page they were on, or to the home page. Anyone know how to send them back to the Category of the product they were on?

Now I will go back and clean up the Update and Remove links in their respective templates with the change I made to Continue Shopping to make them "buttons" too.

Closer to what I want.

Total Hosting 03-05-2006 08:23 PM

And now, here are the cleaned up Update and Remove "buttons" for the cart. Remember, this is around line 59:
Code:

<div style="padding: 8px 0px;">
<table width="100%"><tr><td valign="top">
{if $js_enabled}
{include file="buttons/button.tpl" button_title=$lng.lbl_update style="button" href="javascript: document.cartform.submit()" js_to_href="Y"}
{/if}</td>
<td valign="top">
{include file="buttons/button.tpl" button_title=$lng.lbl_delete_item style="button"  href="cart.php?mode=delete&productindex=`$products[product].cartid`"}
</td><td valign="top">
{if $products[product].product_options ne ''}
{if $config.UA.platform eq 'MacPPC' && $config.UA.browser eq 'MSIE'}
{include file="buttons/edit_product_options.tpl" href="javascript:window.open('`$catalogs.customer`/popup_poptions.php?target=cart&id=`$products[product].cartid`','POptions','width=400,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');" js_to_href="Y"}
{else}
{include file="buttons/edit_product_options.tpl" href="javascript:window.open('`$catalogs.customer`/popup_poptions.php?target=cart&id=`$products[product].cartid`','POptions','width=400,height=350,toolbar=no,status=no,scrollbars=yes,resizable=no,menubar=no,location=no,direction=no');"}
{/if}
{/if}</td>
</tr></table>

</div>


Nice and simple!

Total Hosting 03-07-2006 08:01 PM

why use home.php instead of history go
 
Ok,

One thing to keep in mind, is that if you are going to use the STATIC catalog feature, which I strongly suggest, you should send people back to "home.php" instead of using the javascript history.go(-1) in your Continue Shopping button. That's because if they add to cart, then the history would kick them out of your store (the dynamic part).

You want to try and keep them inside to be able to checkout and make you $$$.


All times are GMT -8. The time now is 05:21 PM.

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