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)
-   -   Wholesale pricing table on products.tpl? (https://forum.x-cart.com/showthread.php?t=15514)

balinor 07-28-2005 10:18 AM

Wholesale pricing table on products.tpl?
 
I seem to remember adding this to a 3.x branch of the cart a long time ago, but that cart is no longer around and I can't seem to track down any posts that cover this. Before I re-invent the wheel, has anyone managed to get the wholesale pricing table to appear on the single column products page (products.tpl)? Thanks!

Light Speed 07-31-2005 07:02 PM

Wouldn't it have to have an instance for each product so if you have 6 products showing on products.tpl wouldn't you have six wholesale tables? Seems like that would be a mess.

balinor 08-01-2005 03:36 AM

Which is why I don't want to attempt it if someone else has already done it :)

sundance 12-12-2005 08:35 AM

Sounds like nobody has already done it...

I am going to have a crack at this tonight - I have just had my first flush of success updating elitedimensions 'extra fields on products.tpl' mod, so might have a go at this, too...

Something along the lines of... select * from xcart_pricing where productid = pid, and then build the table if there are more than one results...

dunno - that seems unwieldy to be honest - perhaps I will actually make an extra field to indicate whether the product HAS wholesale pricing and then do the SQL based on that... hmm.. not that clean either...

Still, all part of my learning curve. I'll keep you 'post'ed
Rob.

Light Speed 12-12-2005 10:19 AM

But doesn't the version of the cart that you are using 4.0.17 not use a extra table to display wholesale pricing like the old carts did? It just changes the actual price if someone is logged in as a wholesale member.

sundance 12-12-2005 02:34 PM

Thanks Light Speed - although I can't find exactly what you are referring to.

Have been fiddling with wholesale prices and they don't appear on the products.tpl list of products even if I am logged in as a wholesale customer.

I may just be looking in the wrong place.

Light Speed 12-12-2005 04:10 PM

Where did you enter the wholesale price?
Did you apply it to a wholesale member level?

If so then in both product.tpl and products.tpl the prices listed will automatically update to the wholesale price if logged in as a wholesale member.

balinor 12-12-2005 04:14 PM

We are talking about quantity discounts, not member-specific pricing.

Light Speed 12-12-2005 05:36 PM

Quote:

Originally Posted by balinor
We are talking about quantity discounts, not member-specific pricing.


I thought the topic title for this thread was "Wholesale pricing table on products.tpl"?

I was discussing wholesale pricing.........

balinor 12-12-2005 06:16 PM

Yes, quantity discounts are wholesale pricing. If you have quantity ranges set up, it displays a little html chart of the price ranges.

Light Speed 12-12-2005 09:10 PM

Quote:

Originally Posted by balinor
Yes, quantity discounts are wholesale pricing. If you have quantity ranges set up, it displays a little html chart of the price ranges.


I have not seen the little wholesale table since moving to the 4.x branch.

I also see no place in the default cart install to define quantity discounts. Is this done with a mod?

sundance 12-13-2005 01:49 AM

Hi balinor and Light.

Let me just clarify what I was talking about - I know the terminology 'wholesale pricing' isn't very helpful here.

As balinor suggests, we aren't looking at the wholesale member pricing - we are looking at the quantity discounts set in the 'Wholesale prices' section under 'modify product' in the [admin] section, like this:

http://www.x-cart.com/demo/provider/product_modify.php?mode=select&productid=17437&sec tion=wholesale

Once these prices have been entered, a 'wholesale prices' box appears in the product.tpl, for the members for whom you have set the membership level - which can be All members. This isn't a very good description of what the box is, it should be a 'quantity discounts' box, but that is the terminology used in the 'cart.

However, this quantity discounts box does not appear in the products.tpl, and that is what I am starting to code now - something that shows the 'quantity discounts' box in products.tpl

More soon,
Rob.

balinor 12-13-2005 03:46 AM

Good explination :) And yes, getting that box to appear on the products.tpl is a bit of work.

sundance 12-13-2005 08:44 AM

Ok - I'm really starting to get somewhere with this.

I should think I will have something to show you all within the next day.

My primary concern at the moment is that the mod is hack-o-rific, and I am going to have to make it neat and tidy in order to release it as anything you could safely describe as a mod.

I can't believe how rusty my php is - I am still fighting a mental battle to remember how to construct and reference associative arrays. It is hurting my head.

Still, have to go out for dinner now - more soon.

Rob.

Light Speed 12-13-2005 09:41 AM

Ah HA!

I use this feature totally differently so I never see the table anymore. I only enter one wholesale price and apply it to a wholesale membership.

This just changes the actual price depending on memberlevel and does not bring up the table. Adding more than one brings up the table.

Really this section now allows you to set wholesale pricing and volume discount. I did not know that and I have been using the cart for almost three years. 8O

Sorry to cause a fuss. Good luck in your quest :)

sundance 12-13-2005 05:20 PM

No problem Light Speed.

It is the terminology that was confusing, not You. Please don't worry about causing a fuss, I would have felt a right muppet if I had continued to do the work and it HAD been something that was already done...

I have finished the mod now, in the sense that it is working, and it is displaying a table on my products.tpl similar to the one on the product.tpl when you have set quantity discount 'Wholesale Prices' under the product modification screen.

It is now 3am here, the coffee is just wearing off, so I will tidy it up and publish it after some sleep.

I am reluctant to post this URL to it working, because the site it is working on is NOWHERE NEAR finished... but you can see the mod in operation here:

Edit*
Sorry URL edited out while I tidy code.
/Edit*

I show you that category just to prove it works with more than one line of quantity discounts.

Sleep beckons. I will give you the code later when it is neat enough.
Rob.

Light Speed 12-13-2005 06:04 PM

Good job!

That site makes me want to have a glass of wine :)

balinor 12-13-2005 06:05 PM

Nice work Sundance! Having done this once before (on 3.x) I remember what a nightmare it was. Looking forward to seeing the completed mod!

sundance 12-14-2005 02:33 AM

Ok,

I haven't really tidied it up very much... sorry - got to go out to lunch (it's a tough life). It hasn't got a proper mod layout, it is all just embedded in the products.tpl using {php} brackets (I know! I know!), and it is probably not as efficient as it could be in its use of arrays.

EDIT: Still bug-fixing - currently have fixes for:
displaying wholesale prices when there aren't any (especially in search results)


It does work for me, though.... I promise I will tidy it up later - I just thought you might like to see it!

Here is my mod for products.tpl

You have to put this code in your products.tpl where you want the table to appear... obviously a table may not suit your needs - my next release of the mod will be tidier and hopefully clearer to see how you can customize it to your won look and feel.

Code:

{assign var="pid" value=$products[product].productid}

{* sundance:extra_fields start *}
{assign var="pid" value=$products[product].productid}

{* get wholesale wholesale pricing data for product *}
{php}
$prodid=$this->_tpl_vars['pid'];

$results = func_query("SELECT * FROM xcart_pricing WHERE productid='$prodid' ORDER BY quantity");
$this->assign("sv_val",$results);
{/php}

{* clear count and array values for each product to appear *}
{php}$i=0;
$boqu="";
$bopr="";
{/php}

{* scan through each set of wholesale pricing *}
{foreach from=$sv_val item=field}

{php}
$boqu[]=$this->_tpl_vars['sv_val'][$i]['quantity'] ;
$bopr[]=$this->_tpl_vars['sv_val'][$i]['price'] ;
$i++;

{/php}

{/foreach}



<table bgcolor="#e9e9e9" border="0" cellspacing="5" cellpadding="0">
  <tr>

{* set up before-and-after array keys and delimiters for display quantiity values *}
{php}
foreach ($boqu as $key => $entry) {
$pre = " - ".($entry-1);
$prerec = ($key-1);
$next = ($key+1);
if ($boqu[$next]!="") {
$nextrec = " - ".($boqu[$next]-1);
} else {
$nextrec = "+";
}
{/php}
{* setup initial price and discount colums *}
{php}if ($prerec==0) {
{/php}
  <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>
            {php}
            echo "Quantity Purchased:";
            {/php}
          </td>
        </tr>
        <tr>
        <td>
            {php}
            echo "Unit Price:";
            {/php}
        </td>
        </tr>
    </table>
    </td>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
              <td>
            {php}
            echo "$boqu[$prerec]$pre";
            {/php}
          </td>
        </tr>
        <tr>
        <td>
            {php}
            echo "$bopr[$prerec]";
            {/php}
        </td>
        </tr>
    </table>
    </td>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
          <td>
            {php}
            echo "$boqu[$key]$nextrec";
            {/php}
          </td>
        </tr>
        <tr>
        <td>
          {php}
          echo "$bopr[$key]";
          {/php}
        </td>
        </tr>
    </table>
    </td>
{php}
}
{/php}
{* display additional columns for multiple prices: *}
{php}
if ($prerec>=1) {
{/php}
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
          <td class="DialogTitle">

            {php}
            echo "$boqu[$key]$nextrec";
            {/php}
          </td>
        </tr>
        <tr>
        <td>
          {php}
          echo "$bopr[$key]";
          {/php}
        </td>
        </tr>
    </table>
    </td>
{php}}{/php}


{php}
} // foreach end
{/php}

  </tr>
</table>


So fiddle about with it - comments and questions are welcome.... I accept that the formatting won't suit everybodys products.tpl layout, and even more that it is a dirty hack - I will work on making it more digestible later,

Rob.

frankdux 09-26-2006 08:56 AM

Re: Wholesale pricing table on products.tpl?
 
Sundance, did this approach work out ok for you?... or does anyone have this working?

rcg 11-01-2006 09:38 AM

Re: Wholesale pricing table on products.tpl?
 
I'm intersted in a variant of this... the table is fine on the product.tpl but I would like to display the lowest price (teaser) on products.tpl... for example:

Widget 123
Price: As low as... $3.25



The details page (product.tpl) would have the pricing laid out... example:

Price: 4.99

2-5 6-10 11-20 21+
$4.50 $4.00 $3.75 $3.25

arinks 04-24-2008 10:03 AM

Re: Wholesale pricing table on products.tpl?
 
I could not get this to work.

It's been quite some time and was hoping if anyone knows of a mod that can achieve this ?

Displaying the wholesale pricing table on the products (products.tpl) page.

balinor 04-24-2008 10:43 AM

Re: Wholesale pricing table on products.tpl?
 
That's because this thread applies to an old version of X-Cart, the code in 4.1 is significantly different.


All times are GMT -8. The time now is 02:20 AM.

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