View Single Post
  #1  
Old 01-30-2010, 08:32 PM
  PC Doctor's Avatar 
PC Doctor PC Doctor is offline
 

Advanced Member
  
Join Date: Apr 2003
Location: Cincinnati, OH USA
Posts: 38
 

Default Select Options (Variants) Redirect Button Mod for X-Cart v4.3.0

Hello Everyone,

Update 3/18/10 - X-Cart v4.3.1 has fixed this bug below, and now you can use this mod directly, see below.
This mod goes hand-in-hand with a 4.3.0 bug fix (I call it the Product Options Redirect Bug). I have posted this bug and it's fix here: (you MUST apply this fix to use this mod)
http://forum.x-cart.com/showthread.php?t=52053

The bug is confirmed by X-Cart and they provided me with patch files to fix it (see link above). It has to do with an option in X-Cart that is supposed to redirect you to a products' detail page when that product has options and you click the add-to-cart button when viewing it's category listing.

Anyway, that is described and fixed in the post above.

When I was able to finally fix this bug, I wanted to take it a step further by changing the 'Add to Cart' button for products that have options to a button that says 'Select Options', and then display the price separately.
The purpose of this mod is, in the category products listing, for any products that have variants or options, instead of showing the normal 'Buy Now' black button with the price in it, to instead change that button to say 'Select Options' and display 'Starting from: $xx.xx' price above the button. With the reasoning that, using this mod in conjunction with the Admin setting checked: Modules Options > Product Options > Redirect customer who clicks 'Buy Now' or 'Add to Wishlist' button of a product with options to the product details page - because with this option on, for a product with options, clicking its buy now button will not simply add it to the cart, it will redirect to that products detail page. Hence changing that products buy now button to say 'Select Options.

Here is an example of this mod, showing products with and without options:
http://www.fixmypcdoctor.com/home.php?cat=2

This is done by editing skin1/customer/main/buy_now.tpl. Be sure to make a backup of this file before you change it.
Around line 147 where it says:

Code:
{elseif $active_modules.Wishlist && ($config.Wishlist.add2wl_unlogged_user eq "Y" || $login ne "")} <div class="button-row"> {include file="customer/buttons/add_to_wishlist.tpl" href="javascript: submitForm(document.orderform_`$product.productid`_`$product.add_date`, 'add2wl'); return false;"} </div> {/if} {else} <div class="buttons-row nopad"> <------------EDIT HERE--------------------> {include file="customer/buttons/button.tpl" type="input" additional_button_class="cart-button add-to-cart-button" button_title=$smarty.capture.price_button title=$lng.lbl_add_to_cart} <------TO HERE - DELETE THIS LINE---------> {if $product.appearance.dropout_actions and $js_enabled} <div class="button-separator"></div> {include file="customer/buttons/add_to_list.tpl" id=$product.productid form_name="orderform_`$product.productid`_`$product.add_date`"} {elseif $active_modules.Wishlist && ($config.Wishlist.add2wl_unlogged_user eq "Y" || $login ne "")} <div class="button-separator"></div>

Change it to this: Updated 3/18/10 - See post #6 below
Code:
{elseif $active_modules.Wishlist && ($config.Wishlist.add2wl_unlogged_user eq "Y" || $login ne "")} <div class="button-row"> {include file="customer/buttons/add_to_wishlist.tpl" href="javascript: submitForm(document.orderform_`$product.productid`_`$product.add_date`, 'add2wl'); return false;"} </div> {/if} {else} <div class="buttons-row nopad"> {*----------------------CHANGE TO SELECT OPTIONS BUTTON FOR PRODUCTS WITH OPTIONS-------------*} {if $product.variantid || $product.is_product_options} {include file="customer/buttons/button.tpl" type="input" additional_button_class="cart-button add-to-cart-button" button_title="Select Options" title="Select Options"} {else} {include file="customer/buttons/button.tpl" type="input" additional_button_class="cart-button add-to-cart-button" button_title=$smarty.capture.price_button title=$lng.lbl_add_to_cart} {/if} {*--------------------------------------------------------------------------------------------*} {if $product.appearance.dropout_actions and $js_enabled} <div class="button-separator"></div> {include file="customer/buttons/add_to_list.tpl" id=$product.productid form_name="orderform_`$product.productid`_`$product.add_date`"} {elseif $active_modules.Wishlist && ($config.Wishlist.add2wl_unlogged_user eq "Y" || $login ne "")} <div class="button-separator"></div>

This will detect if a product has options and if so display the "Select Options" button, otherwise it will display the price/cart button. And if you click the "Select Options" button, you will be directed to that products' detail page.

Now, since the button no longer displays the product price, I made another modification to show the price. This is also in skin1/customer/main/buy_now.tpl.
Around line 91 where it says:
Code:
<div class="quantity"><strong>{$lng.txt_out_of_stock}</strong></div> {elseif $is_matrix_view} <div class="quantity-empty"></div> {else} <---------EDIT HERE------------------> <br /> <-----TO HERE--REMOVE THIS <br />-----> {/if} {if $product.appearance.buy_now_buttons_enabled} {if $js_enabled} {if $product.appearance.has_price}

Change it to this: Updated 3/18/10 - See post #6 below
Code:
<div class="quantity"><strong>{$lng.txt_out_of_stock}</strong></div> {elseif $is_matrix_view} <div class="quantity-empty"></div> {else} {*-------------------DISPLAY PRICE WHEN USING SELECT OPTIONS BUTTON----------------------*} {if $product.variantid || $product.is_product_options} <table cellspacing="0" class="product-properties"> <tr> <td class="property-name product-price"> {$lng.lbl_our_price}: <span class="product-price-value">{include file="currency.tpl" value=$product.taxed_price tag_id="product_price"}</span> </td> </tr> </table> {/if} {*---------------------------------------------------------------------------------------*} {/if} {if $product.appearance.buy_now_buttons_enabled} {if $js_enabled} {if $product.appearance.has_price}

This will display the product price above the "Select Options" button and will only display the price like this if the product has options.

I hope this mod helps someone! Please be sure to view my bug fix post (link at the top) as you will need to apply it before you use this modification (No longer needed in X-Cart v4.3.1). I am using Vivid Dreams - Chromo version of X-Cart 4.3.0, I am not positive if the other templates use the same syntax and parameters for button generation, but if not it should be fairly simple to adapt.

Let me know if anyone has any questions and if you use this mod, I'd like to hear what you think. I don't claim to have the most efficient way of doing this, if anyone has any input I'd certainly like to hear it.

Regards,
Gregory
__________________
PS3 EZ Chill - Internal Cooling Fan Mod Kit
Overheating/YLOD Prevention for Your Playstation 3
www.PS3ezChill.com

Fix-My-PC-Doctor
PC and Game Repair Services
www.FixMyPCDoctor.com
X-Cart 4.3.2
Reply With Quote