Custom Price Calculation based on atrributes??

Posts: 8
Joined: 03/20/2008

Hi everyone,

I am trying to make a pricing-methode work, picture this:

- I have one product called "kalf"

- I have 3 prices for that product based on the qty:

> 1 kilo meat for: $9.95
> (when you buy more than) 5 kilo meat for: $7,50 (a kilo)
> (when you buy more than) 10 kilo meat for: $5,00 (a kilo)

- [ qty ]

- I'v also made 3 atributes (atribute name "price per"):
> "1 Kilo"
> "5 kilo"
> "10 kilo"

What I want is when a customer enters the qty, the price wil be calculated as above (without the customer selecting an atribute) , but I just can't find out how to to do that exactly. I've searched the forums etc. and I came up with the folliwing:

By using the Custom Price Calculation based on the atributes (the 3 prices)

It would look something like this (i am new to php, so i am trying)

if($item->qty > 0) {
$item->price = [sell_price] == ??[price_per] [1kilo]??;
}
if($item->qty > 5) {
$item->price = [sell_price] == ??[price_per] [5kilo]??;
}
if($item->qty > 10) {
$item->price = [sell_price] == ??[price_per] [10kilo]??;
}

By doing it like this my client doesn't need to change the code but simply edit the atibutes settings per product.

Oh.. I also used the token module, but I don't have any experience with it.

If someone could help me out litle...

Pieter

Posts: 299
Joined: 11/19/2007
Bug FinderGetting busy with the Ubercode.

Pieter,
If you are using Attribute Tokens to try and get those attribute adjustments, that won't work for you. That module is to add tokens that represent what option was selected for a given attribute. In order to get a price adjustment for a given product and a given option, you might need to query the database directly.

You'll also, I guess, want to CSS or form alter out those attributes since you won't want them to be selected during checkout.

Posts: 8
Joined: 03/20/2008

cYu (thanx for for your reply),

I thought that it would be complicated, to do it 'my way'.

ok, but if we don't need to adjust the option (it would be invisible) but only generate a price for the customer based on that option. For example if I want 8 kilogram, the price that I would see would be 8 * $7,50. Could I accomplish that with a specific code for the custom price calculation (based on the option "5kilo" ).

Posts: 299
Joined: 11/19/2007
Bug FinderGetting busy with the Ubercode.

pieter, that is the case where I think you'd need to query the database directly to get that value...accessing uc_product_options based on the nid and oid and then adjusting the price accordingly.