Adjusting prices to exchange rate using single update

Author Message

steve walker

Monday 30 August 2004 6:45:19 am

Hi there,

I am developing a site that sells precious stones, and have a question to ask on developing the pricing methodology for the site.

I need to add to the admin area of the site a point where the dollar rate is inputted.

The price of a stone will always equal 'constant_value X dollar_rate' - adding this to the product template to change the value of the price should be easy.

More difficult is to understand how to add this global variable into the admin area so that the value can be called up as and when...

Any ideas on how to achieve this?

Thanks, Steve

http://www.oneworldmarket.co.uk

Paul Forsyth

Monday 30 August 2004 7:00:24 am

If you know which object contains the value you can write a template operator to retreive it when you need it. Though, you would have to make sure this part isnt cached.

paul

steve walker

Monday 30 August 2004 8:44:22 am

Paul,

The key problem for me is how to add functionality to the admin area so a user can update the value of the dollar. And then use this value to determine values in other areas of the site.

I was thinking I could grab the dollar value by partially implementing:

http://www.ez.no/ez_publish/documentation/development/extensions/building_an_ez_publish_module

and only grabbing the dollar value and using this within the product.tpl page to adjust the price accordingly.?

If this worked well I could remove the need for the user to update the dollar value at all...

Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Tuesday 31 August 2004 12:35:45 am

steve,

work through this example and see if it works for you. once you have this value you can always use it to multiply against other values in your templates to show to users.

do you need users to be able to change it? if so a content object in the admin holding the latest value could store this value.

paul

steve walker

Tuesday 31 August 2004 1:15:48 am

Paul,

Have made some progress on this - the exchange rate extension works very well.

In my template pages I can grab the dollar value using code:

{let rates=fetch( 'eurofxref', 'fxref' )}
Current exchange rates 1 EUR = {$rates.fx.USD|l10n( 'number' )} USD
{/let}

I'm having trouble inserting this into the correct place, however, in order to update the price. I can change price.tpl and perform multiplications, e.g.:

{mul($attribute.content.inc_vat_price,20)|l10n(currency)}

but this only affects the price that is displayed on the product page. If you click 'add to basket', the 'unmultiplied' price, i.e. $attribute.content.inc_vat_price gets added to the basket.

It seems I need to go further back and adjust the price before it gets used within any of the templates or stored in a variables that are used to add prices to the basket.

Starting to search the kernel files seemed to be my next option - do you have any other approaches or knowledge of the price components that could help?

Thanks, Steve.

http://www.oneworldmarket.co.uk

Paul Forsyth

Tuesday 31 August 2004 1:36:02 am

Have a look in 'kernel/shop/basket.php'. The price you see in the basket comes from the product itself and not the template. You need a way to inject the corrected price into the object for this to work. Maybe you can patch the kernel slightly to do this in basket.php?

paul

steve walker

Tuesday 07 September 2004 1:43:04 am

Paul,

I am going to look into patching the kernel for this, thanks for the pointers. Before I do though I wanted to examine how I could achieve another pricing issue as it may have remifications for this one.

In my (by now must be infamous!) diamond webshop, the user - once they have chosen a stone - gets the option of adding the stone to the basket, or going on to choose a ring to go with the stone.

The good news is there will only be 6 or so rings to choose from. But when the user passes from their chosen stone to the 'choose associated ring' page, the price of the rings will be adjusted to take into account the stone that is to go with it.

I tried to persuade the client that getting the user to simply add a stone to the basket, then a ring would be easier ;) but unfortunately they dont want the price of the ring to be explicit :(

Because of this it looks as though I need to be able to adjust the basket price on the page rather than at the kernel level?? Ideally I'd like to find an easy work around, but being able to choose associated ring with the stone is absolutely essential to the site.

Any thoughts on this one?

Steve.

http://www.oneworldmarket.co.uk

steve walker

Friday 10 September 2004 3:18:28 am

Paul,

Well, I think I have a possible solution here. Given that the client isnt going to be offering discounts on items the easiest way to make global price adjustments is to use the existing discount mechanism and create a discount that applies to all products and is the adjustment ratio for changing dollar prices.

I'll remove the template code that informs the customer where discounts have been applied so this invisible to the client.

With regards to my thread of carrying cumulative pricing information between pages, I'll start a seperate thread for that as its a bit of a monster topic :(

Thanks for advice on this.

Steve.

http://www.oneworldmarket.co.uk

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.