X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Product Variants and Product Name, Product List Price (https://forum.x-cart.com/showthread.php?t=52569)

XCart4Life 11-04-2011 05:15 PM

Re: Product Variants and Product Name, Product List Price
 
Success!!!! :D/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.

XCart4Life 11-04-2011 11:30 PM

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.

cflsystems 11-29-2011 01:46 PM

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
        );


andyk96 05-02-2012 11:10 PM

Re: Product Variants and Product Name, Product List Price
 
Does anyone have away to do this in Version 4.4.5?

Spiceworld 05-02-2012 11:51 PM

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 :(

andyk96 05-02-2012 11:58 PM

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.

andyk96 05-03-2012 12:07 AM

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.

andyk96 05-03-2012 12:21 AM

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 :(


andyk96 05-03-2012 11:34 PM

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

Warwick 06-08-2012 03:35 AM

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.


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

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