You are here:  » Best price calculated on the basis of both the price and the delivery price?


Best price calculated on the basis of both the price and the delivery price?

Submitted by apa on Wed, 2009-11-25 15:26 in

Hi,

On my site book price-comparison website sometimes it's not the best (in total) price thats on top. See for instance.. {link saved}

Could I make it so that the best price/option is chosen on basis of both freight and price combined?

Kind regards,
Anders

Submitted by support on Wed, 2009-11-25 15:44

Hello Anders,

Yes - I see that you have already added a "fragt" field to your site. There are various levels at which this modification can be implemented.

The easiest way is just to re-arrange the prices table; but this would mean that the search results (where it says "From ...." would not be accurate) and also the main product on the page would be wrong.

So much better; is that since you have both fields present in the database; is to add the delivery field to the "price" field during import. All of the SQL will then work without modification; and you can still show the price excluding delivery if you want to in the prices table by using (price-delivery).

To do this, in your includes/admin.php around about line 169 (but this will have changed of course as you have added a new field), look for this code:

    $record[$admin_importFeed["field_price"]] = tapestry_decimalise($record[$admin_importFeed["field_price"]]);

And, assuming that your delivery field is called field_fragt, REPLACE the above with:

    $record[$admin_importFeed["field_fragt"]] = tapestry_decimalise($record[$admin_importFeed["field_fragt"]]);
    $record[$admin_importFeed["field_price"]] = tapestry_decimalise($record[$admin_importFeed["field_price"]]);
    $record[$admin_importFeed["field_price"]] = $record[$admin_importFeed["field_price"]] + $record[$admin_importFeed["field_fragt"]];

With that in place, after re-importing all feeds the price field should now hold a total price. What you would then want to do (so that the customer does not thing the delivery is extra to your total price!) is change html/prices.php; as described:

- Change the title of the Price column to "Total Price"
- Add a new column infront of the "Fragt" column with the title "Price"
- For the code to display the new "Price" column, use:

<td><strong><?php print $config_currencyHTML.($product["price"]-$product["fragt"]); ?></strong></td>

Of course if you're not sure about any of the above changes, email me the files and I'll check it out for you...

Cheers,
David.

Submitted by apa on Wed, 2009-11-25 19:39

Beautiful - couldn't be easier...

Actually I am using the category field for the "Fragt", so I only had to add you last line to the admin.php file and change field_fragt to field_category.

{link saved}

Thanks a million!