JQuery - Duda carrito compra utilizo la libreria simpleCart (JS)

 
Vista:
Imágen de perfil de Gabriel

Duda carrito compra utilizo la libreria simpleCart (JS)

Publicado por Gabriel (1 intervención) el 28/10/2015 15:34:31
Hola:

Estoy realizando una web con carro de compras. Para el carro de compras utilizo la libreria simpleCart (JS)

1
2
3
4
5
6
7
8
9
10
<div class="item simpleCart_shelfItem" id="item-01">
	<div class="info">
		<div class="dots"></div>
		<span class="name item_name">1. TARO SHRIMP</span>
		<span class="price item_price">$ 8.50</span>
	</div>
	<div class="description">Shrimp wrapped in taro, deep fried and served with chili sauce</div>
	<div class="legend"><span>SPICY</span><a class="add item_add" href="javascript:;">ADD</a></div>
	<input type="hidden" value="1" class="item_Quantity">
</div>

y logro enviarlo por mail de esta manera

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// SIMPLECART.JS
simpleCart({
	checkout: {
 
		type: "SendForm" ,
		url: "sendcart.php" ,
		// http method for form, "POST" or "GET", default is "POST"
		method: "POST" ,
		// url to return to on successful checkout, default is null
		success: "success.php" ,
		// url to return to on cancelled checkout, default is null
		cancel: "cancel.php"
 
 
	},
		cartColumns: [
		{ attr: "name" , label: "Name" } ,
		{ attr: "price" , label: "Price", view: 'currency' } ,
		{ view: "decrement" , label: "&nbsp;" , text: "-" } ,
		{ attr: "quantity" , label: "Qty" } ,
		{ view: "increment" , label: "&nbsp;" , text: "+" } ,
		{ attr: "total" , label: "SubTotal", view: 'currency' } ,
		{ view: "remove" , text: "Remove" , label: "&nbsp;" }
	],
 
 
	extra_data: {
		houseno: document.getElementById("houseno").value,
		street: document.getElementById("street").value,
		city: document.getElementById("city").value,
		postcode: document.getElementById("postcode").value,
		phone: document.getElementById("phone").value,
		email: document.getElementById("email").value,
		cartid: "12321321"
	}
 
 
 
});
// simple callback example
simpleCart.bind( 'beforeAdd' , function( item ){
	//alert("modal");
	jQuery('.modal').modal({
		backdrop:    true,
	});
});
 
simpleCart.bind( 'beforeCheckout' , function( data ){
	data.houseno = document.getElementById("houseno").value;
	data.street = document.getElementById("street").value;
	data.city = document.getElementById("city").value;
	data.postcode = document.getElementById("postcode").value;
	data.phone = document.getElementById("phone").value;
	data.email = document.getElementById("email").value;
 
});


Pero tengo dos problemas que no logro implementar, a ver si me pueden ayudar como hacerlo:

1º tendria que validar primero los campos del formulario, teniendo en cuenta que el formulario esta hecho de esta manera

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<div class="modal-body">
	<div class="simpleCart_items"></div>
	<span class="simpleCart_quantity"></span> items - <span class="simpleCart_total"></span>
 
	<ul class="deliveryaddress">
		<li><label>Street</label><input type="text" name="street" id="street" /></li>
		<li><label>House Number</label><input type="text" name="houseno" id="houseno" /></li>
		<li><label>City</label><input type="text" name="city" id="city" /></li>
		<li><label>Postcode</label><input type="text" name="postcode" id="postcode" /></li>
		<li><label>Phone</label><input type="text" name="phone" id="phone" /></li>
		<li><label>Email</label><input type="text" name="email" id="email" /></li>
	</ul>
	</div>
	<div class="modal-footer">
	<button type="button" class="btn btn-default" data-dismiss="modal">Add more</button>
	<a href="javascript:;" class="btn btn-primary simpleCart_checkout">Checkout</a>
</div>

2º Necesitaria agregar un campo select en el carrito que me permita elegir entre unidades y gramos (que aumentaria/disminuiria cada 500 gr), y dependiendo de eso que la cantidad, precio y total se adapte.

Espero me puedan ayudar con estos dos puntos.

Desde ya muchas gracias!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder