View Single Post
  #12  
Old 11-04-2011, 11:30 PM
  XCart4Life's Avatar 
XCart4Life XCart4Life is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 62
 

Default Re: Product Variants and Product Name, Product List Price

This is a Product Variant - List Price Mod for X-Cart 4.4.4.

I moved some of the product options .tpl files to my skin folder with the same folder structure so I could modify them without changing the original files.
The line numbers are not accurate use them as a reference...just search and find the line of code you are looking for.

Modded Files:
/skin/your_skin/modules/Product_Options/check_options.tpl
/skin/your_skin/modules/Product_Options/product_variants.tpl
/skin/your_skin/customer/main/product_details.tpl
/modules/Product_Options/product_variants.php
/skin/common_files/modules/Product_Options/func.js
/skin/common_files/main/product_details.tpl

Ok let's get started!

First add list_price field to your 'xcart_variants' table in your database. Make sure it is the last entry in the table. I used phpMyAdmin from my site's cpanel:
list_price DECIMAL 12,2

/skin/your_skin/modules/Product_Options/check_options.tpl
This pulls list_price from the database and puts it into an array.

find (around line 40):
PHP Code:
'{$v.productcode|wm_remove|escape:javascript}',
{
$v.W_is_png|default:0}, 

add this below:
PHP Code:
{$v.list_price|default:$v.list_price|default:'0'}, 

/skin/your_skin/modules/Product_Options/product_variants.tpl
This code adds the list_price field to the admin product variants area.

find (around line 115):
PHP Code:
<td class="DataTable">{$lng.lbl_in_stock}</td>
<
td class="DataTable">{$lng.lbl_price}</td

add this below (don't forget to add $lng.lbl_variant_list_price to your langauge labels... My label says 'List Price'):
PHP Code:
<td class="DataTable">{$lng.lbl_variant_list_price}</td

find (around line 133):
PHP Code:
<td class="DataTable"><input type="text" size="5" name="vs[{$k}][avail]" value="{$v.avail|formatnumeric}/></td>
<
td nowrap="nowrap" class="DataTable"><input type="text" size="7" name="vs[{$k}][price]" value="{$v.price|formatprice}/> 

add this below:
PHP Code:
<td nowrap="nowrap" class="DataTable"><input type="text" size="7" name="vs[{$k}][list_price]" value="{$v.list_price|formatprice}/> 

/skin/your_skin/customer/main/product_details.tpl
This sets the id for list_price so later it can be changed with the func.js.

find(around line 96):
PHP Code:
{if $product.appearance.has_market_price and $product.appearance.market_price_discount gt 0
<
tr

modify existing line to match:
PHP Code:
{if $product.appearance.has_market_price and $product.appearance.market_price_discount gt 0
<
tr>
<
td class="property-name product-taxed-price" colspan="3">{$lng.lbl_market_price}: <span id="list_price">{currency value=$product.list_price}</span></td

/modules/Product_Options/product_variants.php
Without this code your list_price wouldn't update in the database when you press 'apply changes'.

find (around line 122):
PHP Code:
$v['weight'] = func_convert_number($v['weight']);
$v['avail'] = func_convert_numeric($v['avail']); 

add this below:
PHP Code:
$v['list_price'] = func_convert_numeric($v['list_price']); 

find (around line 128 ):
PHP Code:
'weight'     => $v['weight'],
'avail'     => $v['avail'], 

add this below:
PHP Code:
'list_price'     => $v['list_price'], 

/skin/common_files/modules/Product_Options/func.js
This code updates the list price when a customer selects a variant. And the other code fixes the save % so it changes correctly when the customer changes to a different product variant.

find (around line 147):
Code:
/* Change product code */ if (document.getElementById('product_code')) document.getElementById('product_code').innerHTML = variants[variantid][0][5];

add this below:
Code:
/* Change list price */ if(document.getElementById('list_price')) document.getElementById('list_price').innerHTML = price_format(variants[variantid][0][7]);

find (around line 58 ):
Code:
orig_price = variants[variantid][0][4];
change to this:
Code:
/*orig_price = variants[variantid][0][4];*/ list_price = variants[variantid][0][7];

/skin/common_files/main/product_details.tpl
This code is optional. It disables editing list price from the product management area in admin and makes a link to product variants.

find (around line 205):
PHP Code:
<td class="FormButton" nowrap="nowrap">{$lng.lbl_list_price} <span class="Text">({$config.General.currency_symbol}):</span></td>
  <
td class="ProductDetails"><input type="text" name="list_price" size="18" value="{$product.list_price|formatprice|default:$zero}/></td

change to match this:
PHP Code:
<td class="FormButton" nowrap="nowrap">{$lng.lbl_list_price} <span class="Text">({$config.General.currency_symbol}):</span></td>
  <
td class="ProductDetails">
  {if 
$product.is_variants eq 'Y'}
  <
b>{$lng.lbl_note}:</b> {$lng.txt_pvariant_edit_note|substitute:"href":$variant_href}
  {else}
  <
input type="text" name="list_price" size="18" value="{$product.list_price|formatprice|default:$zero}/>
  {/if} 

I compiled this after I modded my site. I have not tested this walk through. This is a complicated mod so forgive me if I missed something.
__________________
X-Cart Pro v4.2.2 [Win]
X-Cart Pro v4.2.3 [Win]
X-Cart Pro v4.4.4 [Win]
Reply With Quote