Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Set your own price product

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-24-2015, 09:33 AM
 
Burpomatic Burpomatic is offline
 

Member
  
Join Date: Jan 2015
Posts: 18
 

Question 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,
__________________
Alex

Business 5.3.2.5 Crisp White
Reply With Quote
  #2  
Old 03-31-2015, 03:14 PM
 
Burpomatic Burpomatic is offline
 

Member
  
Join Date: Jan 2015
Posts: 18
 

Default Re: Set your own price product

No one?
__________________
Alex

Business 5.3.2.5 Crisp White
Reply With Quote
  #3  
Old 04-01-2015, 12:39 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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).
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #4  
Old 04-01-2015, 02:49 AM
 
Burpomatic Burpomatic is offline
 

Member
  
Join Date: Jan 2015
Posts: 18
 

Default 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,
__________________
Alex

Business 5.3.2.5 Crisp White
Reply With Quote
  #5  
Old 04-01-2015, 03:10 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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;
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:56 AM.

   

 
X-Cart forums © 2001-2020