magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Cart/Minicart not updating prices when Zero VAT customer group is assigned when logged in #10567

Open tprocter-ldg opened 7 years ago

tprocter-ldg commented 7 years ago

Cart/Minicart not updating prices when Zero VAT customer group is assigned when logged in, until you go through to the billing step of checkout and then go back to update the cart.

Preconditions

  1. Magento 2.1.5
  2. Theme - Magento Luma

VAT SETUP All VAT codes are supplied without the country prefix. Stores > Taxes > Tax Rules > Add New Tax Rule Tax Rule Information Name: Zero VAT Tax Rate: Click ‘Add New Tax Rate’

Additional Settings Customer Tax Class: Click ‘Add New Tax Class’

Stores > Taxes > Tax Zones and Rates > Add New Tax Rate Tax Identifier: Zero VAT Zip/Post is Range: unticked Zip/Post Code: State: Country: Spain Rate Percent: 0.00

Stores > Other Settings > Customer Groups > Add New Customer Group Group Name: Zero VAT Customer Group Tax Class: Zero VAT Customer

Stores > Configuration > Customers > Customer Configuration > CHANGE SCOPE TO SPANISH WEBSITE LEVEL > Create New Account Options screen shot 2017-08-17 at 12 30 54

Stores > Configuration > Sales > Tax screen shot 2017-08-17 at 12 34 49 screen shot 2017-08-17 at 12 35 13 screen shot 2017-08-17 at 12 35 36

Steps to reproduce

Product example being used:

Expected result

Actual result

gewaechshaus commented 7 years ago

Confirm

tprocter-ldg commented 7 years ago

Hi there,

The issue seems to be that the totals are not recollected on address save.

I have implemented a work around for this issue as follows:

app/code/Vendor/Module/etc/di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Customer\Model\Address">
        <plugin name="limitless_recollect_totals" type="Vendor\Module\Plugin\RecollectTotalsPlugin" />
    </type>
</config>

app/code/Vendor/Module/Plugin/RecollectTotalsPlugin.php

<?php

namespace Vender\Module\Plugin;

use Magento\Checkout\Model\Session;
use Magento\Customer\Model\Address;

class RecollectTotalsPlugin
{
    /**
     * @var \Magento\Checkout\Model\Session
     */
    private $checkoutSession;

    public function __construct(Session $checkoutSession)
    {
        $this->checkoutSession = $checkoutSession;
    }

    public function afterSave(Address $subject, $result)
    {
        $quote = $this->checkoutSession->getQuote();
        $quote->setTriggerRecollect(true);
        $quote->getResource()->save($quote);
        return $result;
    }
}

app/code/Vendor/Module/etc/frontend/sections.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="customer/address/formPost">
        <section name="cart"/>
        <section name="checkout-data"/>
    </action>
</config>

I have also added a preference for Magento\Tax\Model\Calculation.php and have overridden the getRateRequest() method. In here I have removed the following outer if statement only, as the $customerTaxClass is always populated and so will never be reset:

if ($customerTaxClass === null || $customerTaxClass === false) { ...

Thanks to @Vinai for his assistance with this one! :)

orlangur commented 7 years ago

@tprocter-ldg want to make the fix a part of core maybe? :)

If not, we probably need a process to make bugs with known fixes as 'up for grabs'.

tprocter-ldg commented 7 years ago

Will do @orlangur :)

magento-engcom-team commented 7 years ago

@tprocter-ldg, thank you for research. Could you please submit pull request with your fix?

tprocter-ldg commented 7 years ago

Hi @magento-engcom-team

Pull request has been created here.

Thank you

magento-engcom-team commented 7 years ago

@tprocter-ldg, thank you for your report. We were not able to reproduce this issue by following the steps you provided. Please provide more details of your site settings, or try to reproduce this issue on a clean installation.

okorshenko commented 6 years ago

Hi @tprocter-ldg Please post pull request here: https://github.com/magento/magento2/pulls So that it can be processed.

tprocter-ldg commented 6 years ago

Hi @okorshenko

PR has now been posted in https://github.com/magento/magento2/pulls.

Thank you

magento-engcom-team commented 6 years ago

@tprocter-ldg, thank you for your report. We've created internal ticket(s) MAGETWO-81672 to track progress on the issue.

m2-assistant[bot] commented 4 months ago

Hi @engcom-Delta. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction: