Skip to main content
deleted 38 characters in body
Source Link

Thanks to Khoa for the big help!

Thanks to Khoa for the big help!

Tweeted twitter.com/StackMagento/status/816375875654430721
added 1145 characters in body
Source Link
eskaliert
  • 175
  • 3
  • 13

Solution for my issue on how to pass jQuery value to Observer (into my Mini-Cart):

<?php

    namespace FarbenGesell\Configuration\Observer;
 
    use Magento\Framework\Event\ObserverInterface;
    use Magento\Framework\App\RequestInterface;
 
    class CustomPrice implements ObserverInterface
    {
        public function __construct(
    \Magento\Framework\App\RequestInterface $request
    )
    {
        $this->_request = $request;
    }
        
        public function execute(\Magento\Framework\Event\Observer $observer) {
            $item = $observer->getEvent()->getData('quote_item');         
            $item = ( $item->getParentItem() ? $item->getParentItem() : $item );

            $custom_price = $this->_request->getParam('custom_final_cal');

            $price = $custom_price;
            $item->setCustomPrice($price);
            $item->setOriginalCustomPrice($price);
            $item->getProduct()->setIsSuperMode(true);
        }
 
    }
?>

Thanks to Khoa for the big help!


Solution for my issue on how to pass jQuery value to Observer (into my Mini-Cart):

<?php

    namespace FarbenGesell\Configuration\Observer;
 
    use Magento\Framework\Event\ObserverInterface;
    use Magento\Framework\App\RequestInterface;
 
    class CustomPrice implements ObserverInterface
    {
        public function __construct(
    \Magento\Framework\App\RequestInterface $request
    )
    {
        $this->_request = $request;
    }
        
        public function execute(\Magento\Framework\Event\Observer $observer) {
            $item = $observer->getEvent()->getData('quote_item');         
            $item = ( $item->getParentItem() ? $item->getParentItem() : $item );

            $custom_price = $this->_request->getParam('custom_final_cal');

            $price = $custom_price;
            $item->setCustomPrice($price);
            $item->setOriginalCustomPrice($price);
            $item->getProduct()->setIsSuperMode(true);
        }
 
    }
?>

Thanks to Khoa for the big help!

added 7700 characters in body
Source Link
eskaliert
  • 175
  • 3
  • 13

I haven't done any changes here. Instead I've created " /Observer/CustomPrice.php" to make it work for Magento 2.1.3 which you see above. The /Controller/Cart/Add.php has been copied from "/vendor/magento/module-checkout/Controller/Cart/Add.php" and only one line had been added:

$params['custom_price']= $params['custom_final_price']; 

I haven't done any changes here. Instead I've created " /Observer/CustomPrice.php" which you see above.

I haven't done any changes here. Instead I've created " /Observer/CustomPrice.php" to make it work for Magento 2.1.3 which you see above. The /Controller/Cart/Add.php has been copied from "/vendor/magento/module-checkout/Controller/Cart/Add.php" and only one line had been added:

$params['custom_price']= $params['custom_final_price']; 
added 7700 characters in body
Source Link
eskaliert
  • 175
  • 3
  • 13
Loading
added 1784 characters in body
Source Link
eskaliert
  • 175
  • 3
  • 13
Loading
deleted 21 characters in body
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156
Loading
added 418 characters in body
Source Link
eskaliert
  • 175
  • 3
  • 13
Loading
Source Link
eskaliert
  • 175
  • 3
  • 13
Loading