1

I need to integrate small stuff.

When I will click add to cart ( bundle product ) then only product added successfully in cart page and then redirect into the checkout page.

So please let me help. Please make sure only bundle product.

0

You can use observer/event at here.

Create Observer event on checkout_cart_add_product_complete.

and set return return_url to request Url as checkout page url when you doing to add to cart.

Observer class:

<?php
namespace StackExchange\Magento\Observer;

use Magento\Framework\Event\ObserverInterface;

class CheckoutCartAddProductComplete implements ObserverInterface
{

    /**
     * @var \Magento\Framework\UrlInterface
     */
    private $url;

    public function __construct(
         \Magento\Framework\UrlInterface $url      
    ) {

        $this->url = $url;
    }
    public function execute(\Magento\Framework\Event\Observer $observer) 
    {
        $product = $observer->getEvent()->getProduct();
        $request= $observer->getEvent()->getRequest();
        if($product->getTypeId() !== 'bundle'){
            return ;
        }
        /**
         * 
         */
        $checkoutUrl = $this->url->getUrl('checkout');
        $request->setParam('return_url',$checkoutUrl);
        return $this;
    }

}

Note that: This solution is work When Setting when After Adding a Product Redirect to Shopping Cart = Yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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