Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
4 fixed grammer
source | link

Through observing the event checkout_cart_product_add_after, I was able to customizedcustomize the price of the item in the cart, now I need to have an observer for customizing its subtotal calculation. What event/events need to be observed?

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically, can it be done through observer or plugin is the solution?

Edit:

Here is my current event:

<event name="sales_quote_collect_totals_before">
        <observer name="customuitemprice" instance="vendor\code\Observer\BindUpdateItem"/>
    </event>

Observer:

class BindUpdateItem implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $quote = $observer->getQuote();
        foreach ($quote->getAllItems() as $item)
        {
            $product = $item->getProduct();
            ?How change the subtotal?

        }
        return $this;
    }
}

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

Edit:

Here is my current event:

<event name="sales_quote_collect_totals_before">
        <observer name="customuitemprice" instance="vendor\code\Observer\BindUpdateItem"/>
    </event>

Observer:

class BindUpdateItem implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $quote = $observer->getQuote();
        foreach ($quote->getAllItems() as $item)
        {
            $product = $item->getProduct();
            ?How change the subtotal?

        }
        return $this;
    }
}

Through observing the event checkout_cart_product_add_after, I was able to customize the price of the item in the cart, now I need to have an observer for customizing its subtotal calculation. What event/events need to be observed?

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically, can it be done through observer or plugin is the solution?

Edit:

Here is my current event:

<event name="sales_quote_collect_totals_before">
        <observer name="customuitemprice" instance="vendor\code\Observer\BindUpdateItem"/>
    </event>

Observer:

class BindUpdateItem implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $quote = $observer->getQuote();
        foreach ($quote->getAllItems() as $item)
        {
            $product = $item->getProduct();
            ?How change the subtotal?

        }
        return $this;
    }
}
3 added 310 characters in body
source | link

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

Edit:

Here is my current event:

$objectManager<event =name="sales_quote_collect_totals_before">
 \Magento\Framework\App\ObjectManager::getInstance       <observer name="customuitemprice" instance="vendor\code\Observer\BindUpdateItem"/>
    </event>

Observer:

class BindUpdateItem implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer);
$cart    {
        $quote = $objectManager$observer->get>getQuote('\Magento\Checkout\Model\Cart');
        foreach ($items$quote->getAllItems() as $item)
        {
 
    echo 'subTotal: '.$cart->getQuote()      $product = $item->getSubtotal>getProduct();
    echo 'grandTotal: '.$cart->getQuote()->getGrandTotal();      ?How change the subtotal?

    echo "<br />";  }
        return $this;
    }
}

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
foreach($items as $item) {
 
    echo 'subTotal: '.$cart->getQuote()->getSubtotal();
    echo 'grandTotal: '.$cart->getQuote()->getGrandTotal();
    echo "<br />";
}

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

Edit:

Here is my current event:

<event name="sales_quote_collect_totals_before">
        <observer name="customuitemprice" instance="vendor\code\Observer\BindUpdateItem"/>
    </event>

Observer:

class BindUpdateItem implements ObserverInterface
{
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $quote = $observer->getQuote();
        foreach ($quote->getAllItems() as $item)
        {
            $product = $item->getProduct();
            ?How change the subtotal?

        }
        return $this;
    }
}
2 added 462 characters in body
source | link

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
foreach($items as $item) {

    echo 'subTotal: '.$cart->getQuote()->getSubtotal();
    echo 'grandTotal: '.$cart->getQuote()->getGrandTotal();
    echo "<br />";
}

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

And basically can it be done through observer or plugin is the solution?

Through observing the event checkout_cart_product_add_after, I was able to customized the price of the item in cart, now I need to have observer for customizing its subtotal calculation. What event/events need to be observed?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
foreach($items as $item) {

    echo 'subTotal: '.$cart->getQuote()->getSubtotal();
    echo 'grandTotal: '.$cart->getQuote()->getGrandTotal();
    echo "<br />";
}

Is it possible to customize the calculation like $cart->setQuote()->getSubtotal() in observer and save the quote?

And basically can it be done through observer or plugin is the solution?

1
source | link