0

It's doesn't work, but I need it done with this code, is it possible?

public function setProdQty($customerId,$upQty,$sendId){

    $quote = $this->quoteFactory->create()->loadByCustomer($customerId);

    $quote->getAllVisibleItems();
    $quote->setitemId($sendId);
    $quote->setqty($upQty);
    return $quote->save();

 }
1
  • $quote->setItemId($sendId) $quote->setQty($upQty) Apr 30, 2019 at 16:07

1 Answer 1

0

try this:

    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 
    echo $cartId=$cart->getQuote()->getId();

    $itemId = 720;
    $itemQty = 1;

    $quote = $this->quoteRepository->getActive($cartId);
    $cartitems = $cart->getQuote()->getAllItems();
    $cartitems->setquoteId($cartId);
    $cartitems->setitemId($itemId);
    $cartitems->setqty($itemQty);

    $quoteItems[] = $cartitems;
    $quote->setItems($quoteItems);
    $this->quoteRepository->save($quote);
    $quote->collectTotals();
3
  • i want change cart product qty from dashboard, $cartId=$cart->getQuote()->getId(); returns null , this way doesn't work . How can i get each customer and update his cart product qty with this code ?
    – Robinio
    Apr 30, 2019 at 16:24
  • would you like to update on customer quote admin?
    – the light
    Apr 30, 2019 at 16:32
  • I created my custom list, and there I show the card information for each customer, and from there I want to change the quantity of goods in the basket for a specific customer.
    – Robinio
    Apr 30, 2019 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.