Custom app for one-page shopping cart

hello guys.
i am trying to to develop one-page shopping cart in custom app and able to fetch all item in table for showing customer (customer can check multiple item that they want to buy and click on “confirm order” button to place the order). i am getting the value of checked item from js code placed in public folder of custom app. but not able to place the order. i tried to give the path of place_order method of erpnext python code, but failled.
following are my code.

var item_code=[];var item_name=[];var dealer_price=[];var avl_qty=[];var order_qty=[];
$(function () {
//Assign Click event to Button.
$("#submit_btn").click(function () {

        $("#item_menu input[type=checkbox]:checked").each(function () {
            var row = $(this).closest("tr")[0];

              item_code.push(row.cells[0].innerHTML);

              item_name.push(row.cells[1].innerHTML);

              dealer_price.push(row.cells[2].innerHTML);

              avl_qty.push(row.cells[4].innerHTML);

              order_qty.push(row.cells[5].getElementsByTagName("input")[0].value);

        });

        //Display selected Row data in Alert Box.
        place_order(item_code,order_qty);
         alert(item_code);
        return false;
    });
});
function place_order(item_code,order_qty) {
	return frappe.call({
		type: "POST",
		method: "erpnext.shopping_cart.cart.place_order",
  args: {
				"item_code":item_code,
				"qty":order_qty
			},
		callback: function(r) {
			if(r.exc) {
				var msg = "";
				if(r._server_messages) {
					msg = JSON.parse(r._server_messages || []).join("<br>");
				}

				$("#cart-error")
					.empty()
					.html(msg || frappe._("Something went wrong!"))
					.toggle(true);
			}
		}
	});
}

is code for place order wrong.
thank you

Hi, I think it’s better to use

method: “erpnext.shopping_cart.cart.update_cart”

method

1 Like

thank you very much for your reply. i am trying that method.