Comments (3)
Can you show me some example codes so I can assist you further?
from cart.
Hey thanks, i actually would now would like to post the data or attributes to 'add' without refreshing the page,. So at the moment it is able to hold the data in the array, but still need press refresh to see that data. I would like to increase the cart count without having to press refresh.
example.php
// Add item
if (isset($_POST['add'])) {
foreach ($products as $product) {
if ($_POST['id'] == $product->id) {
break;
}
}
$cart->add($product->id, $_POST['qty'], [
'price' => $product->price,
'color' => (isset($_POST['color'])) ? $_POST['color'] : '',
'size' => (isset($_POST['size'])) ? $_POST['size'] : '',
]);
}
here is the code I have so far to post to 'add' without refreshing but not sure if its correct. For now when i click the button '.add-to-cartnon' it seems to add the attribute data to 'add' but i dont see it until i hit refresh. so again i would like to update the cart count without having to press refresh
$('.add-to-cartnon').on('click', function(){
var $btn = $(this);
var id = $btn.parent().parent().find('.product-id').val();
var color = $btn.parent().parent().find('.color').val() || '';
var qty = $btn.parent().parent().find('.quantity').val();
var size = $btn.parent().parent().find('.size').val() || '';
var add= $btn.parent().parent().find('.add').val() || '';
$.ajax ({
method: 'post',
url: 'example.php',
data: {
id: id,
color: color,
qty: qty,
size:size,
add:add
},
success: function(data) {
}
});
});
from cart.
It seems like this is Javascript problem. I believed you need to do something at your AJAX success callback.
You need to rewrite the content back to your cart.
from cart.
Related Issues (15)
- Update all Items
- Item not always removing HOT 2
- Cart ID - Undefined index ID HOT 1
- Cart ID missing HOT 1
- can't update quantity of the cart HOT 7
- GREAT CART HOT 3
- If the amount of money differs depending on the color of the same product, how do you implement it? HOT 2
- Error with cart update after removal of first item in product group
- Max Quantity Cart Question
- multiple carts - favorites
- Update error HOT 1
- Update Cart Doesn't work HOT 2
- Change color
- Why Double Array? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cart.