Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeforeCheckout, function (data) problem #533

Open
perdixperdix opened this issue Mar 3, 2018 · 0 comments
Open

BeforeCheckout, function (data) problem #533

perdixperdix opened this issue Mar 3, 2018 · 0 comments

Comments

@perdixperdix
Copy link

I have simpleCart in use together with db with Items.
On load of the website all items available are loaded. If someone puts an item in the cart the 'available' status of this ite is set to 'reserved' in the db through the item_id of it.
This is done with:
simpleCart.bind( "afterAdd" , function( item ){
$.ajax({
url: 'reserved.php',
type: 'post',
data: 'item_id='+item.id(),
});
});
and in the reserved.php by
$items = intval($_POST['item_id']);
$sql = "UPDATE item SET status='RESERVED' WHERE itemnr = '$items'";
This part without any trouble.(HURRAY!)
If someone wants to checkout (im my case through paypal) the status of the item(s) in the cart should be set to 'sold', basically in the same way as above.
This should be done with:
simpleCart.bind( "beforeCheckout" , function(data){
data.id = document.getElementsByClassName("item_id").value;
var item = document.getElementsByClassName("simpleCart_items");
$.ajax({
url: 'sold.php',
type: 'post',
data: 'item_id='+item.id(),
});
});
and in the sold.php by
$items = intval($_POST['item_id']);
$sql = "UPDATE item SET status='SOLD' WHERE itemnr = '$items'";
This doesn't work, message in the log: Type Error item.id() is not a function
Some part is obviously missing and perhaps it is quite simple, but I am lost here..
Does anybody have suggestions ?
Thx in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant