Skip to content

BeforeCheckout, function (data) problem #533

@perdixperdix

Description

@perdixperdix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions