6

I created quote with custom price from Magento admin, it works fine but it does not work multiple currency.

e.g) I created quote to customer with custom price $10 (USD currency), when customer checks it displays the amount $10 in cart page when the customer switch currency it displays $10 without currency conversion.

I have reproduced the scenario in default vanilla setup as well.

is there anyway to achieve custom price works with multiple currency?

8
  • 2
    it is a magento bug
    – Amit Bera
    Commented Feb 18, 2019 at 14:19
  • @AmitBera thanks. do you aware any patch available for this issue? is it a known bug? if yes, please share the ticket link, I need to know the status of this bug. Commented Feb 18, 2019 at 15:17
  • @AmitBera somebody implemented it in Magento 1.X stackoverflow.com/questions/37827188/… is that correct approach to do it Commented Jul 30, 2019 at 11:53
  • @BilalUsean Did you solved this ? Commented Jul 6, 2020 at 9:17
  • @AmitBera any implementation on this i have a same issue? Commented Jul 7, 2020 at 10:33

1 Answer 1

0

For that, I have the same issue regarding custom price with multi-currency setup,

but not working when currency change due to custom price,

And I have added the custom price with this solution code like,

https://webkul.com/blog/magento2-set-custom-price-of-product/

But when switch the currency but price didn't update due to our custom price

So I have applied the solution For that and it's worked fine with custom price,

<event name="controller_action_predispatch"><observer name="force_storecode_redirect" instance="Mconnect\Csproduct\Observer\ForceStorecodeRedirectObserver"shared="false" /></event>

To apply this event and set the observer,

<?php


public function execute(\Magento\Framework\Event\Observer $observer)
{

    if(!empty($_POST) && (count($_POST) > 0) && (isset($_POST['currency']))){
        $currentStore = $this->storeManager->getStore()->getCode();
        $baseUrl = $this->storeManager->getStore()->getBaseUrl();
        $switchCurrency = $_POST['currency'];
        $basecuurency= $this->storeManager->getStore()->getBaseCurrencyCode();
        
        
        
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $priceCurrencyFactory = $objectManager->get('Magento\Directory\Model\CurrencyFactory');
        $storeManager = $objectManager->get('Magento\Store\Model\StoreManagerInterface');
        
        $cart = $objectManager->get('\Magento\Checkout\Model\Cart');
        $quotea = $cart->getQuote();
        $quoteId = $quotea->getId();
        $quote = $this->quoteRepository->get($quoteId);
    $allVisibleItems = $cart->getQuote()->getAllVisibleItems();
    foreach ($quote->getAllItems() as $item) {
        $getprice =$this->_helper->getpricebyprdId($item->getId()); 
        $itemAmount = $item->getProduct()->getFinalPrice();
    
        $rate = $priceCurrencyFactory->create()->load($basecuurency)->getAnyRate($switchCurrency);
        $itemAmount = $itemAmount * $rate;
        
        $item->setCustomPrice($itemAmount);
        $item->setOriginalCustomPrice($itemAmount); 
        $item->getProduct()->setIsSuperMode(true);  
    }$quote->save();
    }
}

Your Answer

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

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