News:

Support the VirtueMart project and become a member

Main Menu

Single Product Purchase

Started by piffero123, March 10, 2013, 15:55:17 PM

Previous topic - Next topic

piffero123

Hi and sorry for my bad english.
I'm Roberto from Rome, using Virtuemart 2 and Joomla 2.5
I need to modify the cart code, to set just one product purchase.
The customer should add just one (no digital) product in cart.

In Virtuemart 1, the file was ps_cart.php
Can you tell me the name of same or similar file and directory in Virtuemart 2, and where and how change the code in?
Best regards,
Roberto

Milbo

FE/helpers/cart.php function add
use something like if count($this->products>0) return false, or so
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

piffero123

Thank you for reply but not yet solution:

This is the piece of code for the function add:

public function add($virtuemart_product_ids=null,&$errorMsg='') {
      $mainframe = JFactory::getApplication();
      $success = false;
      $post = JRequest::get('default');

      if(empty($virtuemart_product_ids)){
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array'); //is sanitized then
      }

      if (empty($virtuemart_product_ids)) {
         $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_CART_ERROR_NO_PRODUCT_IDS', false));
         return false;
      }

             
I have added the line at the beginning of that code:


public function add($virtuemart_product_ids=null,&$errorMsg='') {
      $mainframe = JFactory::getApplication();
      $success = false;
      $post = JRequest::get('default');

               
                if (count($this->products>0));
                        return false;
                }

                if(empty($virtuemart_product_ids)){
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array'); //is sanitized then
      }

      if (empty($virtuemart_product_ids)) {
         $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_CART_ERROR_NO_PRODUCT_IDS', false));
         return false;
      }   


I don't know if the sintax is correct, but now site is a blank page with: "Parse error: syntax error, unexpected T_FOREACH in .........../home/components/com_virtuemart/helpers/cart.php on line 328

[attachment cleanup by admin]

piffero123

No solutions yet...thanks for your attention. If you can I would have the string of code to insert..and the exact place in code.
It is urgent.
Best Regards,
Roberto

piffero123


gunblaze

Sorry if i'm late here.

You can try this:
public function add($virtuemart_product_ids=null,&$errorMsg='') {
      $mainframe = JFactory::getApplication();
      $success = false;
      $post = JRequest::get('default');
      if (count($this->products>0)){
         $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_CART_ERROR_ONLY_1_PRD', false));
         return false;
      }
      ...


then go to your language file in /language/en-GB/en-GB.com_virtuemart.ini and find: COM_VIRTUEMART_CART_ERROR_NO_PRODUCT_IDS

Add the following line above:

COM_VIRTUEMART_CART_ERROR_ONLY_1_PRD="There can only be 1 product at any 1 time"

This should allow you to only add 1 product at one type to cart
Do you run your own Store using virtuemart as well?
Link up with me! Pm me to partner up.
http://www.casualstyle.net

gunblaze

Apologize, there's a syntax error.

It should be the following:

if(count($this->products)>0){
         $mainframe->enqueueMessage(JText::_('COM_VIRTUEMART_CART_ERROR_ONLY_1_PRD', false));
         return false;
}
Do you run your own Store using virtuemart as well?
Link up with me! Pm me to partner up.
http://www.casualstyle.net