I want to get items that added to checkout cart and show that/those in other page.
I have tried many different ways, but in Magento 2 im not been able to do it.
Can you help me out?
Thank you
cartcheckoutmagento2PHPphtml
I want to get items that added to checkout cart and show that/those in other page.
I have tried many different ways, but in Magento 2 im not been able to do it.
Can you help me out?
Thank you
So after debugging every single cache possible it actually turned out to be browser caching the site, this was happening for everybody that visited the site, why I still have no idea.
I added the following in .htaccess
which seems to have resolved the issue
<FilesMatch "\.(html|htm|js|css|php)>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</FilesMatch>
First copied from
app/code/core/Mage/Bundle/Helper/Catalog/Product/Configuration.php
file and put it to
app/code/local/Mage/Bundle/Helper/Catalog/Product/Configuration.php
After replace code from function getBundleOptions()
public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
{
$options = array();
$product = $item->getProduct();
/**
* @var Mage_Bundle_Model_Product_Type
*/
$typeInstance = $product->getTypeInstance(true);
// get bundle options
$optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
$bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
if ($bundleOptionsIds) {
/**
* @var Mage_Bundle_Model_Mysql4_Option_Collection
*/
$optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
// get and add bundle selections collection
$selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
$bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
if (!empty($bundleSelectionIds)) {
$selectionsCollection = $typeInstance->getSelectionsByIds(
unserialize($selectionsQuoteItemOption->getValue()),
$product
);
$bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
foreach ($bundleOptions as $bundleOption) {
if ($bundleOption->getSelections()) {
$option = array(
'label' => $bundleOption->getTitle(),
'value' => array()
);
$bundleSelections = $bundleOption->getSelections();
foreach ($bundleSelections as $bundleSelection) {
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $qty . ' x ' . $this->escapeHtml($bundleSelection->getName())
. ' ' . Mage::helper('core')->currency(
$this->getSelectionFinalPrice($item, $bundleSelection)
);
}
}
if ($option['value']) {
$options[] = $option;
}
}
}
}
}
return $options;
}
TO
public function getBundleOptions(Mage_Catalog_Model_Product_Configuration_Item_Interface $item)
{
$options = array();
$product = $item->getProduct();
/**
* @var Mage_Bundle_Model_Product_Type
*/
$typeInstance = $product->getTypeInstance(true);
// get bundle options
$optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
$bundleOptionsIds = $optionsQuoteItemOption ? unserialize($optionsQuoteItemOption->getValue()) : array();
if ($bundleOptionsIds) {
/**
* @var Mage_Bundle_Model_Mysql4_Option_Collection
*/
$optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
// get and add bundle selections collection
$selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
$bundleSelectionIds = unserialize($selectionsQuoteItemOption->getValue());
if (!empty($bundleSelectionIds)) {
$selectionsCollection = $typeInstance->getSelectionsByIds(
unserialize($selectionsQuoteItemOption->getValue()),
$product
);
$bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
foreach ($bundleOptions as $bundleOption) {
if ($bundleOption->getSelections()) {
$option = array(
'label' => $bundleOption->getTitle(),
'value' => array()
);
$bundleSelections = $bundleOption->getSelections();
foreach ($bundleSelections as $bundleSelection) {
$thumbnail = Mage::helper('catalog/image')->init($bundleSelection, 'thumbnail')->resize();
$imageUrl = '<img src="'.$thumbnail.'" width="75" height="75"/>';
$qty = $this->getSelectionQty($product, $bundleSelection->getSelectionId()) * 1;
if ($qty) {
$option['value'][] = $imageUrl.' '. $qty . ' x ' . $this->escapeHtml($bundleSelection->getName())
. ' ' . Mage::helper('core')->currency(
$this->getSelectionFinalPrice($item, $bundleSelection)
);
}
}
if ($option['value']) {
$options[] = $option;
}
}
}
}
}
return $options;
}
Best Answer
Here is the simpliest example
Folder structure:
1 magento_root/app/code/Furman/NewChekout/etc/module.xml
2 magento_root/app/code/Furman/NewChekout/registration.php
3 magento_root/app/code/Furman/NewChekout/composer.json
4 magento_root/app/code/Furman/NewChekout/etc/frontend/routes.xml
5 magento_root/app/code/Furman/NewChekout/Controller/Cart/Index.php
6 magento_root/app/code/Furman/NewChekout/view/frontend/layout/newcheckout_cart_index.xml
(all xml please copy from magento core file to your file: ./magento_root/vendor/magento/module-checkout/view/frontend/layout/checkout_cart_index.xml or from here )
And here is the result:
You can also delete all blocks that you don't want to show, or set your own phtml in xml