I managed to hide the chekout button using a custom module. I followed this threads to achieve this. I can hide the checkout button in mini cart now.But i want to add some condition to show the Proceed to Checkout button. Where i want to pass the cart total value to minicart.js file in my custom module.
Below are the steps i tried
(app/code/Ayakil/app/code/Vendor/Module/etc/di.xml/etc/di.xml).
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Model\DefaultConfigProvider" type="Ayakil\MinicartCustomization\Model\DefaultConfigProvider" />
</config>
My DefaultConfigProvider.php ( app/code/Ayakil/MinicartCustomization/Model/DefaultConfigProvider.php )
<?php
namespace Ayakil\MinicartCustomization\Model;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\Session\SessionManager;
class DefaultConfigProvider extends \Magento\Checkout\Model\DefaultConfigProvider
{
private $coreSession;
public function __construct(
SessionManager $sessionManager
) {
$this->coreSession = $sessionManager;
}
public function getConfig()
{
$output = parent::getConfig();
if($this->coreSession->getVIErequestData()){
$output['session_VIEUserData'] = true;
}else{
$output['session_VIEUserData'] = false;
}
return $output;
}
}
my minicart-mixin.js file like below.
define([
'uiComponent',
'Magento_Customer/js/customer-data',
'jquery',
'ko',
'underscore',
'sidebar',
'mage/translate',
'mage/dropdown'
], function (Component, customerData, $, ko, _) {
'use strict';
var mixin = {
isButtonEnable: function () {
/*You can add your condition here based on your requirements.*/
console.log(window.checkoutConfig.session_VIEUserData);
return false;
}
};
return function (target) {
return target.extend(mixin);
};
});
In my minicart-mixin.js file if i try to access like console.log(window.checkoutConfig.session_VIEUserData);
i am getting an error.
TypeError: window.CheckoutConfig is undefined
My question is how can i pass a variable to minicart-mixin.js and access the data?