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)
-   -   Displaying 'Wholesale price' instead of 'Product price' (https://forum.x-cart.com/showthread.php?t=55253)

Sisom 08-25-2010 11:11 AM

Displaying 'Wholesale price' instead of 'Product price'
 
Hi, I've just made a simple mod for customer/main/product_details.tpl, which changes the text from 'Product price' to 'Wholesale price' if a trade customer is logged in, I edited around line 103, which used to just say


Code:

{$lng.lbl_our_price}:

I replaced that with this:

Code:

{if $product_wholesale ne ''}
        {$lng.lbl_wholesale_price}:
        {else}
        {$lng.lbl_our_price}:
        {/if}


and then added a new language label

lbl_wholesale_price

which says
"Wholesale price"

(or whatever you want for your store).

But I then tried to edit customer/main/products_list.tpl, to do the same thing, on line 84, I changed

Code:


Code:

<span class="price">
{$lng.lbl_our_price}:
</span>


to

Code:

<span class="price">
{if $product_wholesale ne ''}
{$lng.lbl_wholesale_price}:
{else}
{$lng.lbl_our_price}:
{/if}
</span>


but it won't display "Wholesale price" - I presume this is because $product_wholesale doesn't work here. Can anybody tell me what variable I should be using?

If you can help me I can then put this into the Completed Mods section, as I think it will be useful to other users.

Sisom 08-25-2010 11:27 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
Sorry for the empty 'code' box in the message above, this appears to be a bug in the forum - if you edit your message and change the code within the 'code' tags, it adds an extra set of code tags and even when you delete them, it puts them back!


gb2world 08-25-2010 06:34 PM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
Hi Sisom -

Webmaster mode will tell you all the smarty variables that are available to you on any particular page load, so you do not have to guess. You can look in the webmaster mode console to see what wholesale variables are available. If you do not see what you need, then the php file has to be modified to make it available. Here is a post with more information and an example of using the webmaster mode to find smarty variables.

(If it is there - it will probably be in an array. products_t displays multiple products - so $product_wholesale - which applies to only one product, may not have much meaning. If you do not see it - a query needs to be added to the php file to get it for each product and pass it to template with smarty)

Sisom 08-26-2010 07:12 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
Thanks for your help gb2world, I read the other post you had linked to, very helpful indeed, now I understand so much more about how the variables work.

You were right in that there isn't a 'wholesale' variable on the featured products page at all, I shall see if I can work out how to add it to the php file.


One question I have is - in your post about Smarty variables, you used the example of

<p>This product is made by {$product.manufacturer}.</p>

but when I looked in my Webmaster Mode popup, I could only see the variable

$products
not
$product

but when I tried entering something like

<p>Test:{$products.product}</p>

into products_list.tpl, it didn't work, it only works if I use

<p>Test:{$product.product}</p>

Should I also be seeing a

$product
variable in my Webmaster Mode popup window?


I also then tried

<p>Weight: {$product.weight}</p>
and that worked fine - and finally I understand what all those variables are doing in the templates! Many thanks.

cflsystems 08-26-2010 07:43 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
$products is an array. In products_list.tpl there is a foreach to loop through the $products array so $products.xxx won't work for anything there. You have to use the "item" variable form the foreach - in this case $product.xxx
Use the debug window to see the variables and arrays for the page loaded

Sisom 08-26-2010 10:03 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
Thanks very much for explaining that for me Steve, it's all slowly falling into place now.

Sisom 08-26-2010 10:48 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
Quote:

Originally Posted by gb2world
Hi Sisom -

Webmaster mode will tell you all the smarty variables that are available to you on any particular page load, so you do not have to guess. You can look in the webmaster mode console to see what wholesale variables are available. If you do not see what you need, then the php file has to be modified to make it available.


Hi gb2world - how do I find out which php files are being used by each template or page?

gb2world 08-26-2010 09:17 PM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
I don't know if I can answer that one very well for you. I am not aware of any documentation of X-CART architecture and data structure - so I just look through the code and database to figure out how it is built - just doing it in a piecemeal way to figure out whatever it is I am trying to accomplish. I suspect every one who has any success making changes does it similarly, or the x-cart companies may have internal documentation that they share to teach one another.

I normally look at the names of the php files and look around for the appropriate queries or variables and go from there. For example for products, I start at products.php. For an individual product, I start at product.php. When I am looking for something in particular - I grep for the variables names in question, and just look at the code to find the queries that are pulling the data from the database, and the php that is organizing the data and arrays to pass through to the templates with smarty.

I think if you look at this thread, and are able to understand the code changes made, you should be able to figure out how to modify queries to get extra data, and how to add that data to the products array. Unfortunately - it is a little hard to follow because of all the different inputs, and it is not exactly what you are trying to do - but if you can grasp the principles of the query (mysql), php and passing the data through smarty to the template - then you will be able to do a lot of things with it. If you are pulling in new data - you also have to know where it is in the database, and how the tables in the database relate to one another - so you can write a query to get it.

Also - if you have the persistence - here are a couple more threads with examples of msql->php->smarty->template. They have to do with extra fields - but the methods are the same - getting the data in php, storing it in arrays, and passing it to the templates.
http://forum.x-cart.com/showthread.php?t=46059
http://forum.x-cart.com/showthread.php?t=48320

If you can get a start and ask questions here - hopefully I and others can help you. Or - a quicker way might be to post in the Professional Services forum, and just ask someone to do the php for you, and provide you with the smarty arrays, then you can get your site styled and released, and come back and look at the php later.

--

PhilJ 08-27-2010 08:22 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
You could try this mod...
http://forum.x-cart.com/showthread.php?t=38225

Sisom 08-29-2010 06:26 AM

Re: Displaying 'Wholesale price' instead of 'Product price'
 
Thanks for the mod PhilJ, but I was wondering if maybe there is a simpler way to do what I want, because since all areas of the site display the wholesale price correctly for me, presumably
/customer/main/products_list.tpl
at line 88
</span> <span class="price-value">{include file="currency.tpl" value=$product.taxed_price}</span>

is somehow getting the wholesale price. I am hoping there is some sort of 'if' Smarty statement that I can use, something like
{if $product.taxed_price ...
which uses something that means "if $product-taxed_price uses wholesale price" then display 'Wholesale Price'.

Please forgive my ignorance as I'm still learning some of this!


All times are GMT -8. The time now is 12:37 PM.

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