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

Display price as "Low as $x.xx" based on wholesale

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-05-2003, 03:31 AM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default Display price as "Low as $x.xx" based on wholesale

I originally posted this in the Storefront Design area, but I probably should have posted it here instead. Moderators, please feel free to delete the topic in the Storefront Design area.

Here's my question...

Is there a way to display the lowest possible price based on the quantity breaks that are set up in "Wholesale" pricing?

I want to be able to show the best (lowest) price on the category and product pages.

Here is a thought on how it would work:

NOTE: This code is and example and is in no way accurate!


Code:
{if $product_wholesale ne ""} {$lng.lbl_low_price}: {include file="currency.tpl" value=$products[product_low].price} {else} {$lng.lbl_our_price}: {include file="currency.tpl" value=$products[product].price}


The goal would be to pull the lowest price available for the product (and the current member level) and apply it to the "$products[product_low].price" (this variable is not a real existing xcart variable).


Just some thoughts. Any suggestions would be great.

Surely someone has a thought on how this would work. Boomer, Shan, Funky... any thoughts?

Thanks,

Piper
Reply With Quote
  #2  
Old 09-05-2003, 07:50 AM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default

OK, I think I'm on to something here. I found
Code:
$product_wholesale[wi].price
in "customer/main/product_prices.tpl"

I tried putting
Code:
{$product_wholesale[3].price}
into my "customer/main/products.tpl" with the hope of getting it to return the value of the "3+" price. I also tried various combinations of that code, but the closes I got to my goal was when I used
Code:
{$product_wholesale}
the page returned "Array". OK, so I know that $product_wholesale is an array, but how do I grab one part of that array (specifically the "3 or more quantity" part)?

I'm sure that I'm close to the solution, I'm just not versed enough with Smarty to find the correct syntax.

Piper
Reply With Quote
  #3  
Old 09-05-2003, 09:57 AM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default

It works! Here's what I put into my product.tpl:
Code:
{if $product_wholesale ne ""} {section name=wi loop=$product_wholesale} {if $smarty.section.wi.last} {include file="currency.tpl" value=$product_wholesale[wi].price} {/if} {/section} {else} {include file="currency.tpl" value=$product.price} {/if}

Now, that I feel great about that, I'm back to banging my head against the wall because it does not work in the products_t.tpl!

Back to the drawing board.

Piper
Reply With Quote
  #4  
Old 09-05-2003, 10:34 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Getting it into products_t.tpl is flipping difficult.

It is down to the included php files in the products.php being different to those in product.php. But is would be mightily hard to bring them into loops.

Best bet is to amend the sql query that search products in products.php to something like:

Code:
$products = func_query("select $sql_tbl[products].*, MIN($sql_tbl[pricing].price) as lowestprice, MAX($sql_tbl[pricing].quantity) as quantity from $sql_tbl[products], $sql_tbl[pricing] where $sql_tbl[products].productid=$sql_tbl[pricing].productid AND $sql_tbl[pricing].quantity > 1 AND $sql_tbl[products].categoryid='$cat' AND $sql_tbl[products].forsale='Y' and $avail_condition ($sql_tbl[pricing].membership='$membership' or $sql_tbl[pricing].membership='') group by $sql_tbl[products].productid order by orderby");
The selecting of the lowest price is doen in the sql query. It might be easier.

hope this helps you along the way.
__________________
ex x-cart guru
Reply With Quote
  #5  
Old 09-05-2003, 11:51 AM
 
pipercub pipercub is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 82
 

Default

funkydunk,

Thanks for the code and information. It didn't work, but I appreciate the reply just the same!

Here's my thought...

products_t.tpl is already pulling price data for each product from the database. It pulls the price from the "xcart_pricing" table based on the product id. How can I define not only the product id, but the quantity column as well? I guess I should have explained that I only have 3 levels of pricing (which eliminates the need to have a script find the lowest price), so the price that is associated with the product id + a quantity of 3 is always what I need.

In other words
Code:
{include file="currency.tpl" value=$products[product].price}
seems like it's on the right path, but I just need to refine it to recognize (and pull from the database) a price for quantity of 3.

I guess what I need to know (being a mySQL novice) is how do I pull data from a specific space? (in this case it's xcart_pricing+product id+quantity of 3)

Thanks again,
Piper
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 01:28 PM.

   

 
X-Cart forums © 2001-2020