External file cart empties when using browser back button The 2019 Stack Overflow Developer Survey Results Are InModify tax rate on cart quote items and recalculateWhen getting current cart from an external file, it's emptyMagento 1.7.0.2 - Subtotal and grand total doubled in cartMagento 2.1: Invoke urlBuilder->getUrl() in a controller in a custom moduleUpdate QTY checkout cart Magento not working after update to 1.9.2.4Price not getting updated for second product…After rewrite MagentoCustomerModelAccountManagement giving me fatal errorMagento 2: Add a product to the cart programmaticallyWhen press browser back button cart is emptyUpdate the Price of an item when adding to the cart
Why do UK politicians seemingly ignore opinion polls on Brexit?
Aging parents with no investments
Feature engineering suggestion required
How to notate time signature switching consistently every measure
Why is the maximum length of OpenWrt’s root password 8 characters?
What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?
How come people say “Would of”?
Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
FPGA - DIY Programming
Can we generate random numbers using irrational numbers like π and e?
What do the Banks children have against barley water?
What is the closest word meaning "respect for time / mindful"
Is an up-to-date browser secure on an out-of-date OS?
Can one be advised by a professor who is very far away?
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
A poker game description that does not feel gimmicky
For what reasons would an animal species NOT cross a *horizontal* land bridge?
How to answer pointed "are you quitting" questioning when I don't want them to suspect
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Where to refill my bottle in India?
Can a flute soloist sit?
Who coined the term "madman theory"?
If a Druid sees an animal’s corpse, can they Wild Shape into that animal?
External file cart empties when using browser back button
The 2019 Stack Overflow Developer Survey Results Are InModify tax rate on cart quote items and recalculateWhen getting current cart from an external file, it's emptyMagento 1.7.0.2 - Subtotal and grand total doubled in cartMagento 2.1: Invoke urlBuilder->getUrl() in a controller in a custom moduleUpdate QTY checkout cart Magento not working after update to 1.9.2.4Price not getting updated for second product…After rewrite MagentoCustomerModelAccountManagement giving me fatal errorMagento 2: Add a product to the cart programmaticallyWhen press browser back button cart is emptyUpdate the Price of an item when adding to the cart
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the following code in an external file(same domain) to get the current cart details, and I'm getting all details without any issues.
The problem is, when I go to the checkout page using 'Go to checkout' and press browser back button this cart gets empty. I mean only on this external file.
When I click the 'view and edit cart' and uses the browser back button the cart is fine.
Any help would be appreciated!
<?php
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL);
require '/var/www/html/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('MagentoFrameworkAppHttp');
$obj = MagentoFrameworkAppObjectManager::getInstance();
$obj->get('MagentoFrameworkAppState')->setAreaCode('frontend');
$storeManager = $obj->create("\Magento\Store\Model\StoreManagerInterface");
$storeManager->setCurrentStore(1);
$state = $obj->get('MagentoFrameworkAppState');
// Getting the object managers dependencies
$quote = $obj->get('MagentoCheckoutModelSession')->getQuote();
$shoppingcart = $obj->get('MagentoCheckoutModelCart');
$imagehelper = $obj->get('MagentoCatalogHelperImage');
// Get quote and cart items collection
$quote = $shoppingcart->getQuote();
$quoteitems = $quote->getAllItems();
// Getting cart
$cart= $shoppingcart->getCart();
// Getting the subtotal of the cart
$subtotal = number_format($quote->getBaseSubtotal(), 2);
$qty = 0;
$arrProducts = array();
$mediaurl= $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
$baseurl = $storeManager->getStore()->getBaseUrl();
$j = 0;
foreach ($quoteitems as $item)
$arrProducts[$j]['productID'] = $item->getProductId();
$arrProducts[$j]['productName'] = $item->getName();
$arrProducts[$j]['productQty'] = $item->getQty();
$arrProducts[$j]['productPrice'] = number_format($item->getPrice(),2);
$qty += $item->getQty();
$_product = $obj->get('MagentoCatalogModelProduct')->load($item->getProductId());
$arrProducts[$j]['productUrl'] = $_product->getUrlKey();
$arrProducts[$j]['productImage'] = $mediaurl.'catalog/product'.$_product->getSmallImage();
$j++;
?>
<div class="CustomMiniCart">
<?php
if($qty > 0 && !empty($arrProducts)) ?>
<span class="miniCartWrap">
Cart Subtotal: <b>$<?php echo $subtotal; ?></b>
<span class="numItems"><b><?php echo count($arrProducts);?></b> Item(s) in Cart</span>
<a href="https://example.com/checkout/" class="chk">GO TO CHECKOUT</a>
<?php
foreach($arrProducts as $product) ?>
<span class="proWrap">
<span class="left"><a href="https://example.com/<?php echo $product['productUrl'] ?>/"><img src="<?php echo $product['productImage'] ?>" /></a></span>
<span class="right"><a href="https://example.com/<?php echo $product['productUrl']?>/"><?php echo$product['productName']?></a><br><br>
<b>$<?php echo$product['productPrice']?></b><br><br>Qty: <?php echo $product['productQty']?>
</span>
</span>
<?php ?>
<span class="viewcart"><a href="https://example.com/checkout/cart/">VIEW AND EDIT CART</a></span>
</span>
<?php else ?>
<span class="emptyCart">You have no items in your shopping cart.</span>
<?php ?>
</div>
magento-2.1 checkout cart
add a comment |
I have the following code in an external file(same domain) to get the current cart details, and I'm getting all details without any issues.
The problem is, when I go to the checkout page using 'Go to checkout' and press browser back button this cart gets empty. I mean only on this external file.
When I click the 'view and edit cart' and uses the browser back button the cart is fine.
Any help would be appreciated!
<?php
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL);
require '/var/www/html/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('MagentoFrameworkAppHttp');
$obj = MagentoFrameworkAppObjectManager::getInstance();
$obj->get('MagentoFrameworkAppState')->setAreaCode('frontend');
$storeManager = $obj->create("\Magento\Store\Model\StoreManagerInterface");
$storeManager->setCurrentStore(1);
$state = $obj->get('MagentoFrameworkAppState');
// Getting the object managers dependencies
$quote = $obj->get('MagentoCheckoutModelSession')->getQuote();
$shoppingcart = $obj->get('MagentoCheckoutModelCart');
$imagehelper = $obj->get('MagentoCatalogHelperImage');
// Get quote and cart items collection
$quote = $shoppingcart->getQuote();
$quoteitems = $quote->getAllItems();
// Getting cart
$cart= $shoppingcart->getCart();
// Getting the subtotal of the cart
$subtotal = number_format($quote->getBaseSubtotal(), 2);
$qty = 0;
$arrProducts = array();
$mediaurl= $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
$baseurl = $storeManager->getStore()->getBaseUrl();
$j = 0;
foreach ($quoteitems as $item)
$arrProducts[$j]['productID'] = $item->getProductId();
$arrProducts[$j]['productName'] = $item->getName();
$arrProducts[$j]['productQty'] = $item->getQty();
$arrProducts[$j]['productPrice'] = number_format($item->getPrice(),2);
$qty += $item->getQty();
$_product = $obj->get('MagentoCatalogModelProduct')->load($item->getProductId());
$arrProducts[$j]['productUrl'] = $_product->getUrlKey();
$arrProducts[$j]['productImage'] = $mediaurl.'catalog/product'.$_product->getSmallImage();
$j++;
?>
<div class="CustomMiniCart">
<?php
if($qty > 0 && !empty($arrProducts)) ?>
<span class="miniCartWrap">
Cart Subtotal: <b>$<?php echo $subtotal; ?></b>
<span class="numItems"><b><?php echo count($arrProducts);?></b> Item(s) in Cart</span>
<a href="https://example.com/checkout/" class="chk">GO TO CHECKOUT</a>
<?php
foreach($arrProducts as $product) ?>
<span class="proWrap">
<span class="left"><a href="https://example.com/<?php echo $product['productUrl'] ?>/"><img src="<?php echo $product['productImage'] ?>" /></a></span>
<span class="right"><a href="https://example.com/<?php echo $product['productUrl']?>/"><?php echo$product['productName']?></a><br><br>
<b>$<?php echo$product['productPrice']?></b><br><br>Qty: <?php echo $product['productQty']?>
</span>
</span>
<?php ?>
<span class="viewcart"><a href="https://example.com/checkout/cart/">VIEW AND EDIT CART</a></span>
</span>
<?php else ?>
<span class="emptyCart">You have no items in your shopping cart.</span>
<?php ?>
</div>
magento-2.1 checkout cart
add a comment |
I have the following code in an external file(same domain) to get the current cart details, and I'm getting all details without any issues.
The problem is, when I go to the checkout page using 'Go to checkout' and press browser back button this cart gets empty. I mean only on this external file.
When I click the 'view and edit cart' and uses the browser back button the cart is fine.
Any help would be appreciated!
<?php
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL);
require '/var/www/html/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('MagentoFrameworkAppHttp');
$obj = MagentoFrameworkAppObjectManager::getInstance();
$obj->get('MagentoFrameworkAppState')->setAreaCode('frontend');
$storeManager = $obj->create("\Magento\Store\Model\StoreManagerInterface");
$storeManager->setCurrentStore(1);
$state = $obj->get('MagentoFrameworkAppState');
// Getting the object managers dependencies
$quote = $obj->get('MagentoCheckoutModelSession')->getQuote();
$shoppingcart = $obj->get('MagentoCheckoutModelCart');
$imagehelper = $obj->get('MagentoCatalogHelperImage');
// Get quote and cart items collection
$quote = $shoppingcart->getQuote();
$quoteitems = $quote->getAllItems();
// Getting cart
$cart= $shoppingcart->getCart();
// Getting the subtotal of the cart
$subtotal = number_format($quote->getBaseSubtotal(), 2);
$qty = 0;
$arrProducts = array();
$mediaurl= $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
$baseurl = $storeManager->getStore()->getBaseUrl();
$j = 0;
foreach ($quoteitems as $item)
$arrProducts[$j]['productID'] = $item->getProductId();
$arrProducts[$j]['productName'] = $item->getName();
$arrProducts[$j]['productQty'] = $item->getQty();
$arrProducts[$j]['productPrice'] = number_format($item->getPrice(),2);
$qty += $item->getQty();
$_product = $obj->get('MagentoCatalogModelProduct')->load($item->getProductId());
$arrProducts[$j]['productUrl'] = $_product->getUrlKey();
$arrProducts[$j]['productImage'] = $mediaurl.'catalog/product'.$_product->getSmallImage();
$j++;
?>
<div class="CustomMiniCart">
<?php
if($qty > 0 && !empty($arrProducts)) ?>
<span class="miniCartWrap">
Cart Subtotal: <b>$<?php echo $subtotal; ?></b>
<span class="numItems"><b><?php echo count($arrProducts);?></b> Item(s) in Cart</span>
<a href="https://example.com/checkout/" class="chk">GO TO CHECKOUT</a>
<?php
foreach($arrProducts as $product) ?>
<span class="proWrap">
<span class="left"><a href="https://example.com/<?php echo $product['productUrl'] ?>/"><img src="<?php echo $product['productImage'] ?>" /></a></span>
<span class="right"><a href="https://example.com/<?php echo $product['productUrl']?>/"><?php echo$product['productName']?></a><br><br>
<b>$<?php echo$product['productPrice']?></b><br><br>Qty: <?php echo $product['productQty']?>
</span>
</span>
<?php ?>
<span class="viewcart"><a href="https://example.com/checkout/cart/">VIEW AND EDIT CART</a></span>
</span>
<?php else ?>
<span class="emptyCart">You have no items in your shopping cart.</span>
<?php ?>
</div>
magento-2.1 checkout cart
I have the following code in an external file(same domain) to get the current cart details, and I'm getting all details without any issues.
The problem is, when I go to the checkout page using 'Go to checkout' and press browser back button this cart gets empty. I mean only on this external file.
When I click the 'view and edit cart' and uses the browser back button the cart is fine.
Any help would be appreciated!
<?php
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL);
require '/var/www/html/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('MagentoFrameworkAppHttp');
$obj = MagentoFrameworkAppObjectManager::getInstance();
$obj->get('MagentoFrameworkAppState')->setAreaCode('frontend');
$storeManager = $obj->create("\Magento\Store\Model\StoreManagerInterface");
$storeManager->setCurrentStore(1);
$state = $obj->get('MagentoFrameworkAppState');
// Getting the object managers dependencies
$quote = $obj->get('MagentoCheckoutModelSession')->getQuote();
$shoppingcart = $obj->get('MagentoCheckoutModelCart');
$imagehelper = $obj->get('MagentoCatalogHelperImage');
// Get quote and cart items collection
$quote = $shoppingcart->getQuote();
$quoteitems = $quote->getAllItems();
// Getting cart
$cart= $shoppingcart->getCart();
// Getting the subtotal of the cart
$subtotal = number_format($quote->getBaseSubtotal(), 2);
$qty = 0;
$arrProducts = array();
$mediaurl= $storeManager->getStore()->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
$baseurl = $storeManager->getStore()->getBaseUrl();
$j = 0;
foreach ($quoteitems as $item)
$arrProducts[$j]['productID'] = $item->getProductId();
$arrProducts[$j]['productName'] = $item->getName();
$arrProducts[$j]['productQty'] = $item->getQty();
$arrProducts[$j]['productPrice'] = number_format($item->getPrice(),2);
$qty += $item->getQty();
$_product = $obj->get('MagentoCatalogModelProduct')->load($item->getProductId());
$arrProducts[$j]['productUrl'] = $_product->getUrlKey();
$arrProducts[$j]['productImage'] = $mediaurl.'catalog/product'.$_product->getSmallImage();
$j++;
?>
<div class="CustomMiniCart">
<?php
if($qty > 0 && !empty($arrProducts)) ?>
<span class="miniCartWrap">
Cart Subtotal: <b>$<?php echo $subtotal; ?></b>
<span class="numItems"><b><?php echo count($arrProducts);?></b> Item(s) in Cart</span>
<a href="https://example.com/checkout/" class="chk">GO TO CHECKOUT</a>
<?php
foreach($arrProducts as $product) ?>
<span class="proWrap">
<span class="left"><a href="https://example.com/<?php echo $product['productUrl'] ?>/"><img src="<?php echo $product['productImage'] ?>" /></a></span>
<span class="right"><a href="https://example.com/<?php echo $product['productUrl']?>/"><?php echo$product['productName']?></a><br><br>
<b>$<?php echo$product['productPrice']?></b><br><br>Qty: <?php echo $product['productQty']?>
</span>
</span>
<?php ?>
<span class="viewcart"><a href="https://example.com/checkout/cart/">VIEW AND EDIT CART</a></span>
</span>
<?php else ?>
<span class="emptyCart">You have no items in your shopping cart.</span>
<?php ?>
</div>
magento-2.1 checkout cart
magento-2.1 checkout cart
asked 4 mins ago
ASRASR
816
816
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269634%2fexternal-file-cart-empties-when-using-browser-back-button%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269634%2fexternal-file-cart-empties-when-using-browser-back-button%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown