Skip to content

Commit

Permalink
ENGCOM-2205: Make it possible to disable cross-sell on cart page #16569
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Idolov authored Jul 12, 2018
2 parents 6827d2b + 44bfc8b commit d0eca97
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<!--Create Store view -->
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/>
<waitForElementVisible selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="waitForStoreViewBtn"/>
<click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/>
<waitForPageLoad stepKey="waitForProductPageLoad"/>
<selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/>
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Checkout/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<field id="number_items_to_display_pager" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Number of Items to Display Pager</label>
</field>
<field id="crosssell_enabled" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Cross-sell Items in the Shopping Cart</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="cart_link" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="0">
<label>My Cart Link</label>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<delete_quote_after>30</delete_quote_after>
<redirect_to_cart>0</redirect_to_cart>
<number_items_to_display_pager>20</number_items_to_display_pager>
<crosssell_enabled>1</crosssell_enabled>
</cart>
<cart_link>
<use_qty>1</use_qty>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ Payment,Payment
"Item in Cart","Item in Cart"
"Items in Cart","Items in Cart"
"Close","Close"
"Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart"
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
</block>
<container name="checkout.cart.widget" as="checkout_cart_widget" label="Shopping Cart Items After"/>
</container>
<block class="Magento\Checkout\Block\Cart\Crosssell" name="checkout.cart.crosssell" template="Magento_Catalog::product/list/items.phtml" after="-">
<block class="Magento\Checkout\Block\Cart\Crosssell" name="checkout.cart.crosssell" template="Magento_Catalog::product/list/items.phtml" after="-" ifconfig="checkout/cart/crosssell_enabled">
<arguments>
<argument name="type" xsi:type="string">crosssell</argument>
</arguments>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
<actionGroup name="SetTaxClassForShipping">
<amOnPage url="{{AdminSalesTaxClassPage.url}}" stepKey="navigateToSalesTaxPage"/>
<waitForPageLoad stepKey="waitForPageLoad"/>
<conditionalClick selector="{{SalesConfigSection.TaxClassesTab}}" dependentSelector="{{SalesConfigSection.CheckIfTaxClassesTabExpand}}" visible="true" stepKey="expandTaxClassesTab"/>
<waitForElementVisible selector="{{SalesConfigSection.ShippingTaxClass}}" stepKey="seeShippingTaxClass"/>
<uncheckOption selector="{{SalesConfigSection.EnableTaxClassForShipping}}" stepKey="uncheckUseSystemValue"/>
<selectOption selector="{{SalesConfigSection.ShippingTaxClass}}" userInput="Taxable Goods" stepKey="setShippingTaxClass"/>
<click selector="{{SalesConfigSection.TaxClassesTab}}" stepKey="collapseTaxClassesTab"/>
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfig" />
</actionGroup>
<actionGroup name="ResetTaxClassForShipping">
<amOnPage url="{{AdminSalesTaxClassPage.url}}" stepKey="navigateToSalesTaxConfigPagetoReset"/>
<waitForPageLoad stepKey="waitForPageLoad2"/>
<conditionalClick selector="{{SalesConfigSection.TaxClassesTab}}" dependentSelector="{{SalesConfigSection.CheckIfTaxClassesTabExpand}}" visible="true" stepKey="openTaxClassTab"/>
<waitForElementVisible selector="{{SalesConfigSection.ShippingTaxClass}}" stepKey="seeShippingTaxClass2"/>
<selectOption selector="{{SalesConfigSection.ShippingTaxClass}}" userInput="None" stepKey="resetShippingTaxClass"/>
<checkOption selector="{{SalesConfigSection.EnableTaxClassForShipping}}" stepKey="useSystemValue"/>
<click selector="{{SalesConfigSection.TaxClassesTab}}" stepKey="collapseTaxClassesTab"/>
<click selector="{{ContentManagementSection.Save}}" stepKey="saveConfiguration"/>
</actionGroup>
</actionGroups>
3 changes: 3 additions & 0 deletions app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@
<page name="AdminContentManagementPage" url="admin/system_config/edit/section/cms/" area="admin" module="Magento_Config">
<section name="ContentManagementSection"/>
</page>
<page name="AdminSalesTaxClassPage" url="admin/system_config/edit/section/tax/" area="admin" module="Magento_Config">
<section name="SalesTaxClassSection"/>
</page>
</pages>
17 changes: 17 additions & 0 deletions app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="SalesConfigSection">
<element name="TaxClassesTab" type="button" selector="#tax_classes-head"/>
<element name="CheckIfTaxClassesTabExpand" type="button" selector="#tax_classes-head:not(.open)"/>
<element name="ShippingTaxClass" type="select" selector="#tax_classes_shipping_tax_class"/>
<element name="EnableTaxClassForShipping" type="checkbox" selector="#tax_classes_shipping_tax_class_inherit"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<system>
<section id="checkout">
<group id="cart">
<field id="configurable_product_image" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<field id="configurable_product_image" translate="label" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Configurable Product Image</label>
<source_model>Magento\Catalog\Model\Config\Source\Product\Thumbnail</source_model>
</field>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/GroupedProduct/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<system>
<section id="checkout" translate="label" type="text" sortOrder="305" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="cart" translate="label" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="grouped_product_image" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<field id="grouped_product_image" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Grouped Product Image</label>
<source_model>Magento\Catalog\Model\Config\Source\Product\Thumbnail</source_model>
</field>
Expand Down
19 changes: 18 additions & 1 deletion app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
* Calculate how much shipping discount should be applied
* basing on how much shipping should be refunded.
*/
$baseShippingAmount = (float)$creditmemo->getBaseShippingAmount();
$baseShippingAmount = $this->getBaseShippingAmount($creditmemo);
if ($baseShippingAmount) {
$baseShippingDiscount = $baseShippingAmount *
$order->getBaseShippingDiscountAmount() /
Expand Down Expand Up @@ -75,4 +75,21 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}

/**
* Get base shipping amount
*
* @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
* @return float
*/
private function getBaseShippingAmount(\Magento\Sales\Model\Order\Creditmemo $creditmemo): float
{
$baseShippingAmount = (float)$creditmemo->getBaseShippingAmount();
if (!$baseShippingAmount) {
$baseShippingInclTax = (float)$creditmemo->getBaseShippingInclTax();
$baseShippingTaxAmount = (float)$creditmemo->getBaseShippingTaxAmount();
$baseShippingAmount = $baseShippingInclTax - $baseShippingTaxAmount;
}
return $baseShippingAmount;
}
}
Loading

0 comments on commit d0eca97

Please sign in to comment.