View Single Post
  #15  
Old 06-28-2012, 01:28 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Product options in product list

Going even further, here is how to modify the javascript to get the product price to update when the product option is changed. //This will not work with product variants, or with wholesale prices

We begin by submitting the product id with the onchange event:
In /my_skin/modules/Product_Options/customer_options.tpl near line 48:
Replace:
PHP Code:
<select id="po{$v.classid}name="{$poname}"{if $disabledisabled="disabled"{/if}{if $nojs ne 'Y'onchange="javascript: check_options();"{/if}> 
With:
PHP Code:
<select id="po{$v.classid}name="{$poname}"{if $disabledisabled="disabled"{/if}{if $nojs ne 'Y'onchange="javascript: check_options({$product.productid});"{/if}> 
Note: we are simply passing the productid to the check_options() function.

Next before we dive into the JS, lets set the span ID to include the productid on the product page:
In /customer/main/product_details.tpl near line 80:
After:
PHP Code:
{if $product.taxed_price ne 0 or $variant_price_no_empty
Insert:
PHP Code:
{capture name="product_price_id"}product_price{$product.productid}{/capture
And

Replace:
PHP Code:
<span class="product-price-value">{currency value=$product.taxed_price tag_id="product_price"}</span
With:
PHP Code:
<span class="product-price-value">{currency value=$product.taxed_price tag_id=$smarty.capture.product_price_id}</span


Note: the below code references the product price in the template products_list.tpl, you may be using products_t.tpl instead, if your products are arranged in multiple columns. This depends on the settings under General Settings/Appearance - Displaying products. In this case, look near line 116 and make the edit to the span as described below, and include the capture above it.


And on the category page:
In /customer/main/products_list.tpl near line 70:
After:
PHP Code:
<div class="price-row{if $active_modules.Special_Offers ne "" and $product.use_special_price ne ""} special-price-row{/if}"
Insert:
PHP Code:
{capture name="product_price_id"}product_price{$product.productid}{/capture
And

Replace:
PHP Code:
<span class="price">{$lng.lbl_our_price}:</span> <span class="price-value">{currency value=$product.taxed_price}</span
With:
PHP Code:
<span class="price">{$lng.lbl_our_price}:</span> <span class="price-value">{currency value=$product.taxed_price tag_id=$smarty.capture.product_price_id}</span
Next we will edit the JS to reference our newly passed productid, and subsequently change the corresponding span where we appended the productid above.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote