X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Set your own price product (https://forum.x-cart.com/showthread.php?t=71689)

Burpomatic 03-24-2015 09:33 AM

Set your own price product
 
Hello,

I am trying to create a product where customers can enter their own price in an input box. I have managed to modify the price of the item in the getClearPrice() method by decorating the XLite\Model\OrderItem.php file through hardcoding of a module. I added the input box by decorating the default\en\product/quantity/body.tpl. I would like to add up the price with the input the client entered in the input box on the product page. Could anyone give me clues for this?

Thank you,

Burpomatic 03-31-2015 03:14 PM

Re: Set your own price product
 
No one?

qualiteam 04-01-2015 12:39 AM

Re: Set your own price product
 
I believe you should start looking from the controller class that handles the "add to cart" function (\XLite\Controller\Customer\Cart::doActionAdd()) and go deeper until you find where it creates an OrderItem from the product being added.

Then check if it is your "set own price" price product and override the OrderItem price with the value submitted by the user (don't forget to check against hack attempts).

Burpomatic 04-01-2015 02:49 AM

Re: Set your own price product
 
Hello Alex,

thanks for your answer. I'll check out the class you suggested me. But in any case, my biggest problem is to retrieve the submitted value. I've added an input box through the default\en\product/quantity/body.tpl template (I added a second "set your price" box next to the quantity one) and I didn't manage to fetch the value. Perhaps this isn't the best way to do it?

Thanks again,

qualiteam 04-01-2015 03:10 AM

Re: Set your own price product
 
You can get a variable from the request with this code:
Code:

$variable = \XLite\Core\Request::getInstance()->put_your_variable_name_there;


All times are GMT -8. The time now is 01:27 AM.

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