Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Product Variants and Product Name, Product List Price

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 11-04-2011, 05:15 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

Success!!!! I was using an older post on here to add list price to product variants. I'm testing out 4.4.4 but the post was for 4.1 or 4.2 and the file structure has completely changed since. After spending hours and searching through code I finally got it working (the main part at least).

So from the admin side when you log into product variants you have list price as an extra field. When you fill in the field and click apply changes it updates the database with the list price. I also got the list price to change dynamically with the func.js script on the product details page.

Some other things that I still have to work on:
1.) Importing and exporting functionality.
2.) The save% calculation needs to be worked on.
3.) Showing the msrp for the default product variant on the product listings

I promise I will post the files I edited and the changes. I figure I needed to give back because I've used this forum hundreds of times.
__________________
X-Cart Pro v4.2.2 [Win]
X-Cart Pro v4.2.3 [Win]
X-Cart Pro v4.4.4 [Win]
Reply With Quote
  #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

The following user thanks XCart4Life for this useful post:
vasilis (07-26-2014)
  #13  
Old 11-29-2011, 01:46 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,190
 

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

To add to the above - one more file needs to be edited in order to preserve list prices if variants are turned on/off or deleted

Open /modules/Product_Options/func.php and find

Code:
$data = array( 'productid' => $productid, 'avail' => $_product['avail'], 'weight' => $_product['weight'], 'productcode' => $sku, );

and replace with

Code:
$list_price = $vars[$old_variantid]['list_price']; // added by CFL Systems to preserve list_price for variants $data = array( 'productid' => $productid, 'avail' => $_product['avail'], 'weight' => $_product['weight'], 'productcode' => $sku, 'list_price' => $list_price, // added by CFL Systems to preserve list_price for variants );

If using BCS mod for variants with orderby sorting that needs to be added there instead - bug in the mod

Code:
$orderby = $vars[$old_variantid]['orderby']; // added by CFL Systems to preserve orderby for variants - BCSE mod bug $list_price = $vars[$old_variantid]['list_price']; // added by CFL Systems to preserve list_price for variants $data = array( 'productid' => $productid, 'avail' => $_product['avail'], 'weight' => $_product['weight'], 'productcode' => $sku, 'orderby' => $orderby, // added by CFL Systems to preserve orderby for variants - BCSE mod bug 'list_price' => $list_price, // added by CFL Systems to preserve list_price for variants );
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #14  
Old 05-02-2012, 11:10 PM
 
andyk96 andyk96 is offline
 

Member
  
Join Date: Apr 2012
Posts: 13
 

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

Does anyone have away to do this in Version 4.4.5?
__________________
4.4.5
Reply With Quote
  #15  
Old 05-02-2012, 11:51 PM
 
Spiceworld Spiceworld is offline
 

Advanced Member
  
Join Date: Nov 2009
Posts: 81
 

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

This should be standard code in todays market.

Stupid having to keep on adding after each upgrade!

If only they listened to their customers
__________________
4.6.1
Reply With Quote
  #16  
Old 05-02-2012, 11:58 PM
 
andyk96 andyk96 is offline
 

Member
  
Join Date: Apr 2012
Posts: 13
 

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

Ok Got everything where it needs to be, but the price is not changing when you click on the variable. Where did i go wrong.
__________________
4.4.5
Reply With Quote
  #17  
Old 05-03-2012, 12:07 AM
 
andyk96 andyk96 is offline
 

Member
  
Join Date: Apr 2012
Posts: 13
 

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

Also, the part where it says "don't forget to add $lng.lbl_variant_list_price to your langauge labels... My label says 'List Price'"

Where is that done at? Maybe that is my problem?

Thanks for all the help.
__________________
4.4.5
Reply With Quote
  #18  
Old 05-03-2012, 12:21 AM
 
andyk96 andyk96 is offline
 

Member
  
Join Date: Apr 2012
Posts: 13
 

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

Ok Got everything where it needs to be, but the price is not changing when you click on the variable. Where did i go wrong.
Also, the part where it says "don't forget to add $lng.lbl_variant_list_price to your langauge labels... My label says 'List Price'"

Where is that done at? Maybe that is my problem?

Thanks for all the help.


Quote:
Originally Posted by Spiceworld
This should be standard code in todays market.

Stupid having to keep on adding after each upgrade!

If only they listened to their customers
__________________
4.4.5
Reply With Quote
  #19  
Old 05-03-2012, 11:34 PM
 
andyk96 andyk96 is offline
 

Member
  
Join Date: Apr 2012
Posts: 13
 

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

Can anyone give me a hand? I'm stuck and dont know where to turn. Got this far and again it wont change once the variable is clicked. NOt sure what is missing.

Any help would be great
__________________
4.4.5
Reply With Quote
  #20  
Old 06-08-2012, 03:35 AM
  Warwick's Avatar 
Warwick Warwick is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Somewhere on the web through European connection
Posts: 868
 

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

Anybody tried this with 4.2?

A real nasty one to tackle, I now have variants that show a higher sell price when they are selected than the 'normal' list price. This does look very 'unselleable, never noticed of thought about this before though

Example:
Product has three variants; Small, Medium and Large

Small costs 10 dollar
Medium costs 12 dollars
Large costs 14 dollars

Normally the basic variant (small) costs 13 dollars

So now only with the small version the 'normally 13 dollars, our price 10 dollars' is shown
But when the large variant is selected, for example medium, it says 'Normally 13 dollars, our price 14 dollars' .... selling price appearing to be higher than the from price.

In cases off rather cheap products with little difference between variantprices one would say that a solution would be to just set the from price at a higher amount than the most expensive variant.
But this will look suspicious with higher priced products, cretaing huge gaps between the from and for price with the cheapest variant.
__________________
Installs: X-Cart 4.1.x - 4.4.x ∙∙ MySQL version: 5.0.45 ∙∙ Apache version: 2.2.8 (Unix) ∙∙ PHP version: 5.25
X-Cart add-ons: all ∙∙ Mods: A lot; too many ∙∙ Skin templates: Many
∙∙ Experience: Somewhere beyond newbie
-----------------------------------
------------------------------------------------------------------------------------------------------
Looking for the best dutch language pack? 4.1.x - 4.6.x compatibel, native speaker translation! More info
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:10 AM.

   

 
X-Cart forums © 2001-2020