2

How do I call the subtotal for different products in different stores in block .php or view .phtml files?

I set the price of the products manually for different stores.

I want to write a condition to show/not show something in the shopping cart page.

Example:

For subtotal greater than USD30, something will show in US store cart page. For subtotal greater than HK$300, something will show in HongKong Store cart page. For subtotal greater than EUR30, something will show in Europe store cart page.

1 Answer 1

0

I found a solution

Differentiate store by using store code and set different subtotal condition, as below

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$subTotal = $cart->getQuote()->getSubtotal();

$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$storeCode = $storeManager->getStore()->getCode();
?>

<?php if (($storeCode == 'en' && $subTotal >= 30) || ($storeCode == 'my' && $subTotal >= 60) || ($storeCode == 'hk' && $subTotal >= 300)): ?>

Your Answer

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

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