This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Developer » Shop: Dynamic per-order pricing. Is...

Shop: Dynamic per-order pricing. Is it possible?

Shop: Dynamic per-order pricing. Is it possible?

Thursday 03 July 2014 2:35:31 pm - 3 replies

Hello community,

I'm new to both the forums and ez publish in general, and I've been given quite an odd business requirement. Using Community Edition 2013.11, I need to write a module that will create an order using an existing product but with a different price.

So for example: Widget A is already in the shop priced at £1000, and I want to offer it to a user at £123.45. I'll be presenting them with a form where they can accept or ignore the offer.

Is there a way of achieving this without permanently affecting the price of Widget A?

Thanks in advance and I hope I've phrased the question well enough!

Thursday 03 July 2014 11:32:03 pm

Using a custom-operation it would be possible.

Usually the shop-module uses the operation shop:addtobasket.

What you actually need is a setup as follows.

  1. custom module
  2. custom operation

This module and operator are an almost exact copy the "shop/add"-view and the "shop:addtobasket"-operation.
You just add a variable to define a offered price for the item.

It's a little complicated but possible.

As you are new to the ez-publish, i will probably need to tell you that the original php-files can be found at "ezpublish_legacy/kernel/shop"
In there you will find "add.php", "ezshopoperationcollection.php" and the "operation_definition.php".
Those files need to be copied to a new extension of yours and adjusted as required.

To use those files, you need to override the templates, the kernels shop is using.
There you need to address your module.

If there are any more questions, feel free to ask.

Friday 04 July 2014 1:52:54 pm

Thanks for your help! It might be that I'm doing something wrong but when I use a custom version of the addToBasket function I can see the new price by doing var_dump($order->items()), but viewing the basket in the front-end shows the original item's price (which is carried through to the order).

Maybe it's because I'm using Multi-Price items?

Friday 04 July 2014 3:02:06 pm

Well than you probably need to adjust the templates.
As they do not show the value of the item inside the cart, they probably recalculate the price again.

Change the output to use the price of the item.


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from