VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: brandiware on March 21, 2017, 19:21:46 PM

Title: add to cart from within cart pricelist does not work
Post by: brandiware on March 21, 2017, 19:21:46 PM
Hi all,

not sure if this is my ignorance or a bug. When trying to add a product using the below code nothing happens.
The $error variable is empty.
Anything missing here ?

I added the code just before the iteration of the carts product, rendering them onto the cart page.

The code will add a product which comes free based on the actual list of products in the cart.

<?php
$i = 1;
$moertelSumme = 0;

  $moertelProductIDs = array();
  $moertelProductIDs[0] = 1967;
  $moertelProductIDs[1] = 39;
   $this->cart->add($moertelProductIDs,$error);
           
           
foreach ($this->cart->products as $pkey => $prow) {
   $prow->prices = array_merge($prow->prices,$this->cart->cartPrices[$pkey]);
?>
Title: Re: add to cart from within cart pricelist does not work
Post by: brandiware on March 21, 2017, 19:27:13 PM
sorry, it was my ignorance. The product ids were the culprits

$moertelProductIDs[0] = '1967';
  $moertelProductIDs[1] = '39';
Title: Re: add to cart from within cart pricelist does not work
Post by: Milbo on March 22, 2017, 13:02:39 PM
Uhm,.. I wonder myself why it insists on a string, should also work with an integer. Interesting observation, which php version?
Title: Re: add to cart from within cart pricelist does not work
Post by: brandiware on March 28, 2017, 19:11:42 PM
Hi Milbo,

the php is 5.6.18. I can not reliably add and remove products from the cart. I guess I am not using the same functions as called when the update icon is clicked.
The add and remove works by means of updating quantities yet the changes are not consistently made visible.

Any help is greatly appreciated. Once this all works I can publish a responsive version of the cart.

Here is what I do from within my override of default_pricelist.php:

Add a product:

        $this->cart->add($moertelProductIDs,$error);
       $this->cart->updateProductCart($moertelProductIDs,$error);

Delete a product (the quantity is changed to zero but the product still appears):

    $existing_haltermoertel[]=$prow->virtuemart_product_id;
   $this->cart->removeProductCart($existing_haltermoertel);
   $this->cart->updateProductCart($existing_haltermoertel);

From the remark in the updateProductCart func I take it that the removal of 0 qty products is not implemented. Hence there must be another function to call
since hitting the delete icon works.

   public function updateProductCart() {

      $quantities = vRequest::getInt('quantity');
      if(empty($quantities)) return false;
      $updated = false;

      foreach($quantities as $key=>$quantity){
         if (isset($this->cartProductsData[$key]) and !empty($quantity) and !isset($_POST['delete_'.$key])) {
            if($quantity!=$this->cartProductsData[$key]['quantity']){
               $this->cartProductsData[$key]['quantity'] = $quantity;
               $updated = true;
            }

         } else {
            //Todo when quantity is 0,  the product should be removed, maybe necessary to gather in array and execute delete func
            unset($this->cartProductsData[$key]);
            $updated = true;
         }
      }

      $this->setCartIntoSession(true);
      return $updated;
   }
Title: Re: add to cart from within cart pricelist does not work
Post by: Milbo on March 29, 2017, 16:45:38 PM
" that the removal of 0 qty products is not implemented."
That works.

I think you buy some support from me and talk with me about another strategy to solve your problem. It looks like you unecessary hack the core.
Title: Re: add to cart from within cart pricelist does not work
Post by: brandiware on March 31, 2017, 11:27:51 AM
Hi Milbo, I was unaware that default_pricelist.php is part of the core. I can override it.

I would very much appreciate support from you on this issue as well as the issue with many multi-variants.
I still get crashes when using multi-variants above 100. Debug Mode and PHP Developer mode don't produce
any error messages. VM simply reverts to the home page.

When can we set up a support session and how ? Could we use teamviewer ?
Let me know how I can buy this support.

Best Regards
Stefan
Title: Re: add to cart from within cart pricelist does not work
Post by: Milbo on March 31, 2017, 11:37:12 AM
http://extensions.virtuemart.net/support/support-for-1-hour-detail

http://extensions.virtuemart.net/ticket

I use usually skype. Das Ticket gerne auf Deutsch schreiben.
Title: Re: add to cart from within cart pricelist does not work
Post by: Milbo on March 31, 2017, 11:38:17 AM
Maybe you just need to buy this and write your own layout for it.

http://extensions.virtuemart.net/shopper-order/shoppers/rawforms-detail
Title: Re: add to cart from within cart pricelist does not work
Post by: brandiware on April 04, 2017, 09:58:32 AM
Hi Milbo, I have created a ticket with a 1 hour support now. Waiting for your contact.

My Skype is Stefan Brandmeier