I am playing with adding the shopping cart to the checkout shipping and payment pages.
Although I could do this with php via <?php require(DIR_WS_MODULES. 'sideboxes/shopping_cart.php'); ?> , there are some elements missing I would like to include and it would be less intrusive to default code if I could accomplish it with some script instead.
I have seen the use of the browser API tool 'fetch' to accomplish what I want (done on my site using code added via an A/B testing tool).
When I utilize it directly in includes/templates/responsive_classic/templates/tpl_checkout_shipping_default.php, even in a simplified version and set to display the results in the Console, the results I get are that the html of the shopping cart page is pulled in, but the cart is always empty.
What am I missing?
My first guess is this isn't possible because 'fetch' isn't allowing the sql query to run in order to pull in the shopping cart info...yet it worked when applied as a script pushed on the page by an A/B testing tool.
Here is an example of the code
Code:
<script>
fetch('/index.php?main_page=shopping_cart').then(function (response) {
// The API call was successful!
return response.text();
}).then(function (html) {
// This is the HTML from our response as a text string
console.log(html);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
</script>
Bookmarks