• User Newbie

    Implementare mail riepilogativa su plugin carrello

    Un saluto a tutti i membri, ho un plugin jquery per un carrello e-commerce che funziona benissimo, ma vorrei che quando l'utente clicca sul bottone paga mi arrivasse mail riepilogativa dell'ordine, dai dati inseriti nel form dall'utente ai dati del carrello (prodotto, prezzo, quantita' e totale) salvati in session storage.
    Spero possiate aiutarmi.
    Grazie anticipatamente.

    Posto alcuni frammenti di codice jquery per il form e carrello:

    Dati del form

    	_saveFormData: function( form ) {
    		var self = this;
    		var $visibleSet = form.find( "fieldset:visible" );
    		
    		$visibleSet.each(function() {
    			var $set = $( this );
    			if( $set.is( "#fieldset-billing" ) ) {
    				var name = $( "#name", $set ).val();
    				var email = $( "#email", $set ).val();
    				var phone = $( "#phone", $set ).val();
    				var city = $( "#city", $set ).val();
    				var province = $( "#province", $set ).val();
    				var address = $( "#address", $set ).val();
    				var zip = $( "#zip", $set ).val();
    				var country = $( "#country", $set ).val();
    				
    				self.storage.setItem( "billing-name", name );
    				self.storage.setItem( "billing-email", email );
    				self.storage.setItem( "billing-phone", phone );
    				self.storage.setItem( "billing-city", city );
    				self.storage.setItem( "billing-province", province );
    				self.storage.setItem( "billing-address", address );
    				self.storage.setItem( "billing-zip", zip );
    				self.storage.setItem( "billing-country", country );
    			} else {
    				var sName = $( "#sname", $set ).val();
    				var sEmail = $( "#semail", $set ).val();
    				var sCity = $( "#scity", $set ).val();
    				var sProvince = $( "#sprovince", $set ).val();
    				var sAddress = $( "#saddress", $set ).val();
    				var sZip = $( "#szip", $set ).val();
    				var sCountry = $( "#scountry", $set ).val();
    				
    				self.storage.setItem( "shipping-name", sName );
    				self.storage.setItem( "shipping-email", sEmail );
    				self.storage.setItem( "shipping-city", sCity );
    				self.storage.setItem( "shipping-province", sProvince );
    				self.storage.setItem( "shipping-address", sAddress );
    				self.storage.setItem( "shipping-zip", sZip );
    				self.storage.setItem( "shipping-country", sCountry );
    			
    			}
    		});
    	}
    };
    

    Dati carrello prodotto, quantita', prezzo e subtotale

    // Aggiunge articoli al carrello

    	handleAddToCartForm: function() {
    		var self = this;
    		self.$formAddToCart.each(function() {
    			var $form = $( this );
    			var $product = $form.parent();
    			var price = self._convertString( $product.data( "price" ) );
    			var name =  $product.data( "name" );
    			
    			$form.on( "submit", function() {
    				var qty = self._convertString( $form.find( ".qty" ).val() );
    				var subTotal = qty * price;
    				var total = self._convertString( self.storage.getItem( self.total ) );
    				var sTotal = total + subTotal;
    				self.storage.setItem( self.total, sTotal );
    				self._addToCart({
    					product: name,
    					price: price,
    					qty: qty
    				});
    				var shipping = self._convertString( self.storage.getItem( self.shippingRates ) );
    				var shippingRates = self._calculateShipping( qty );
    				var totalShipping = shipping + shippingRates;
    				
    				self.storage.setItem( self.shippingRates, totalShipping );
    			});
    		});
    	},
    
    
    	
                // Visualizza il carrello
    	
    	displayCart: function() {
    		if( this.$formCart.length ) {
    			var cart = this._toJSONObject( this.storage.getItem( this.cartName ) );
    			var items = cart.items;
    			var $tableCart = this.$formCart.find( ".shopping-cart" );
    			var $tableCartBody = $tableCart.find( "tbody" );
    
    			if( items.length == 0 ) {
    				$tableCartBody.html( "" );	
    			} else {
    			
    			
    				for( var i = 0; i < items.length; ++i ) {
    					var item = items*;
    					var product = item.product;
    					var price = this.currency + " " + item.price;
    					var qty = item.qty;
    					var html = "<tr><td class='pname'>" + product + "</td>" + "<td class='pqty'><input type='text' value='" + qty + "' class='qty'/></td>";
    				    	html += "<td class='pprice'>" + price + "</td><td class='pdelete'><a href='' data-product='" + product + "'>&times;</a></td></tr>";
    				
    					$tableCartBody.html( $tableCartBody.html() + html );
    				}
    
    			}
    
    			if( items.length == 0 ) {
    				this.$subTotal[0].innerHTML = this.currency + " " + 0.00;
    			} else {	
    			
    				var total = this.storage.getItem( this.total );
    				this.$subTotal[0].innerHTML = this.currency + " " + total;
    			}
    		} else if( this.$checkoutCart.length ) {
    			var checkoutCart = this._toJSONObject( this.storage.getItem( this.cartName ) );
    			var cartItems = checkoutCart.items;
    			var $cartBody = this.$checkoutCart.find( "tbody" );
    
    			if( cartItems.length > 0 ) {
    			
    				for( var j = 0; j < cartItems.length; ++j ) {
    					var cartItem = cartItems[j];
    					var cartProduct = cartItem.product;
    					var cartPrice = this.currency + " " + cartItem.price;
    					var cartQty = cartItem.qty;
    					var cartHTML = "<tr><td class='pname'>" + cartProduct + "</td>" + "<td class='pqty'>" + cartQty + "</td>" + "<td class='pprice'>" + cartPrice + "</td></tr>";
    				
    					$cartBody.html( $cartBody.html() + cartHTML );
    				}
    			} else {
    				$cartBody.html( "" );	
    			}
    
    			if( cartItems.length > 0 ) {
    			
    				var cartTotal = this.storage.getItem( this.total );
    				var cartShipping = this.storage.getItem( this.shippingRates );
    				var subTot = this._convertString( cartTotal ) + this._convertString( cartShipping );
    			
    				this.$subTotal[0].innerHTML = this.currency + " " + this._convertNumber( subTot );
    				this.$shipping[0].innerHTML = this.currency + " " + cartShipping;
    			} else {
    				this.$subTotal[0].innerHTML = this.currency + " " + 0.00;
    				this.$shipping[0].innerHTML = this.currency + " " + 0.00;	
    			}
    		
    		}
    	},