Skip to content

Commit

Permalink
Merge pull request #381 from magento-south/MAGETWO-36960
Browse files Browse the repository at this point in the history
[SOUTH] Shopping cart + Bugs
  • Loading branch information
AndriyNasinnyk committed Jun 25, 2015
2 parents 3ad1194 + 8bd029f commit 264c105
Show file tree
Hide file tree
Showing 130 changed files with 6,803 additions and 2,431 deletions.
4 changes: 4 additions & 0 deletions app/code/Magento/Backend/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@
<label>European Union Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
</field>
<field id="destinations" translate="label" type="multiselect" sortOrder="40" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Top destinations</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
</field>
</group>
<group id="locale" translate="label" type="text" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Locale Options</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
* @param \Magento\Framework\Url\Helper\Data $urlHelper
* @param \Magento\Framework\Message\ManagerInterface $messageManager
* @param PriceCurrencyInterface $priceCurrency
* @param Configuration $bundleProductConfiguration
* @param \Magento\Framework\Module\Manager $moduleManager
* @param Configuration $bundleProductConfiguration
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.item.renderers">
<block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/item/default.phtml"/>
<block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/item/default.phtml">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions" name="checkout.cart.item.renderers.bundle.actions" as="actions">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit" name="checkout.cart.item.renderers.bundle.actions.edit" template="Magento_Checkout::cart/item/renderer/actions/edit.phtml"/>
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Remove" name="checkout.cart.item.renderers.bundle.actions.remove" template="Magento_Checkout::cart/item/renderer/actions/remove.phtml"/>
</block>
</block>
</referenceBlock>
</body>
</page>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getValuesHtml()
if ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_DROP_DOWN) {
$select->setName('options[' . $_option->getid() . ']')->addOption('', __('-- Please Select --'));
} else {
$select->setName('options[' . $_option->getid() . ']');
$select->setName('options[' . $_option->getid() . '][]');
$select->setClass('multiselect admin__control-multiselect' . $require . ' product-custom-option');
}
foreach ($_option->getValues() as $_value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.item.renderers">
<block class="Magento\Checkout\Block\Cart\Item\Renderer" as="virtual" template="cart/item/default.phtml"/>
<block class="Magento\Checkout\Block\Cart\Item\Renderer" as="virtual" template="cart/item/default.phtml">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions" name="checkout.cart.item.renderers.virtual.actions" as="actions">
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit" name="checkout.cart.item.renderers.virtual.actions.edit" template="Magento_Checkout::cart/item/renderer/actions/edit.phtml"/>
<block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Remove" name="checkout.cart.item.renderers.virtual.actions.remove" template="Magento_Checkout::cart/item/renderer/actions/remove.phtml"/>
</block>
</block>
</referenceBlock>
</body>
</page>
67 changes: 37 additions & 30 deletions app/code/Magento/Checkout/Block/Cart/Item/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

namespace Magento\Checkout\Block\Cart\Item;

use Magento\Checkout\Block\Cart\Item\Renderer\Actions;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Quote\Model\Quote\Item;
use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface;

Expand Down Expand Up @@ -120,10 +122,10 @@ public function __construct(
/**
* Set item for render
*
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param Item $item
* @return $this
*/
public function setItem(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function setItem(Item $item)
{
$this->_item = $item;
return $this;
Expand Down Expand Up @@ -316,19 +318,6 @@ public function getOptionList()
return $this->getProductOptions();
}

/**
* Get item configure url
*
* @return string
*/
public function getConfigureUrl()
{
return $this->getUrl(
'checkout/cart/configure',
['id' => $this->getItem()->getId(), 'product_id' => $this->getItem()->getProduct()->getId()]
);
}

/**
* Get quote item qty
*
Expand Down Expand Up @@ -432,7 +421,7 @@ public function isProductVisible()
/**
* Return product additional information block
*
* @return \Magento\Framework\View\Element\AbstractBlock
* @return AbstractBlock
*/
public function getProductAdditionalInformationBlock()
{
Expand Down Expand Up @@ -529,10 +518,10 @@ public function convertPrice($amount, $format = false)
/**
* Return the unit price html
*
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getUnitPriceHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getUnitPriceHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.item.price.unit');
Expand All @@ -543,10 +532,10 @@ public function getUnitPriceHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $
/**
* Return row total html
*
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getRowTotalHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getRowTotalHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.item.price.row');
Expand All @@ -557,10 +546,10 @@ public function getRowTotalHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $i
/**
* Return item price html for sidebar
*
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getSidebarItemPriceHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getSidebarItemPriceHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.cart.item.price.sidebar');
Expand All @@ -571,10 +560,10 @@ public function getSidebarItemPriceHtml(\Magento\Quote\Model\Quote\Item\Abstract
/**
* Get unit price excluding tax html
*
* @param Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getUnitPriceExclTaxHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getUnitPriceExclTaxHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.onepage.review.item.price.unit.excl');
Expand All @@ -585,10 +574,10 @@ public function getUnitPriceExclTaxHtml(\Magento\Quote\Model\Quote\Item\Abstract
/**
* Get unit price including tax html
*
* @param Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getUnitPriceInclTaxHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getUnitPriceInclTaxHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.onepage.review.item.price.unit.incl');
Expand All @@ -599,10 +588,10 @@ public function getUnitPriceInclTaxHtml(\Magento\Quote\Model\Quote\Item\Abstract
/**
* Get row total excluding tax html
*
* @param Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getRowTotalExclTaxHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getRowTotalExclTaxHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.onepage.review.item.price.rowtotal.excl');
Expand All @@ -613,14 +602,32 @@ public function getRowTotalExclTaxHtml(\Magento\Quote\Model\Quote\Item\AbstractI
/**
* Get row total including tax html
*
* @param Item\AbstractItem $item
* @param Item $item
* @return string
*/
public function getRowTotalInclTaxHtml(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
public function getRowTotalInclTaxHtml(Item $item)
{
/** @var Renderer $block */
$block = $this->getLayout()->getBlock('checkout.onepage.review.item.price.rowtotal.incl');
$block->setItem($item);
return $block->toHtml();
}

/**
* Get row total including tax html
*
* @param Item $item
* @return string
*/
public function getActions(Item $item)
{
/** @var Actions $block */
$block = $this->getChildBlock('actions');
if ($block instanceof Actions) {
$block->setItem($item);
return $block->toHtml();
} else {
return '';
}
}
}
62 changes: 62 additions & 0 deletions app/code/Magento/Checkout/Block/Cart/Item/Renderer/Actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Block\Cart\Item\Renderer;

use Magento\Checkout\Block\Cart\Item\Renderer\Actions\Generic;
use Magento\Framework\View\Element\Text;
use Magento\Quote\Model\Quote\Item;

class Actions extends Text
{
/**
* @var Item
*/
protected $item;

/**
* Returns current quote item
*
* @return Item
*/
public function getItem()
{
return $this->item;
}

/**
* Set current quote item
*
* @param Item $item
* @return $this
*/
public function setItem(Item $item)
{
$this->item = $item;
return $this;
}

/**
* Render html output
*
* @return string
*/
protected function _toHtml()
{
$this->setText('');

$layout = $this->getLayout();
foreach ($this->getChildNames() as $child) {
/** @var Generic $childBlock */
$childBlock = $layout->getBlock($child);
if ($childBlock instanceof Generic) {
$childBlock->setItem($this->getItem());
$this->addText($layout->renderElement($child, false));
}
}

return parent::_toHtml();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Block\Cart\Item\Renderer\Actions;

class Edit extends Generic
{
/**
* Get item configure url
*
* @return string
*/
public function getConfigureUrl()
{
return $this->getUrl(
'checkout/cart/configure',
[
'id' => $this->getItem()->getId(),
'product_id' => $this->getItem()->getProduct()->getId()
]
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Block\Cart\Item\Renderer\Actions;

use Magento\Framework\View\Element\Template;
use Magento\Quote\Model\Quote\Item;

class Generic extends Template
{
/**
* @var Item
*/
protected $item;

/**
* Returns current quote item
*
* @return Item
*/
public function getItem()
{
return $this->item;
}

/**
* Set current quote item
*
* @param Item $item
* @return $this
*/
public function setItem(Item $item)
{
$this->item = $item;
return $this;
}

/**
* Check if product is visible in site visibility
*
* @return bool
*/
public function isProductVisibleInSiteVisibility()
{
return $this->getItem()->getProduct()->isVisibleInSiteVisibility();
}

/**
* Check if cart item is virtual
*
* @return bool
*/
public function isVirtual()
{
return (bool)$this->getItem()->getIsVirtual();
}
}
Loading

0 comments on commit 264c105

Please sign in to comment.