Subversion Repositories wpShopGermany4

Rev

Rev 5767 | Rev 6268 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5767 daniel 1
 
6165 hartmut 2
	var wpsg_vp_vari = new Array();
3
 
4
	function wpsg_vp_switch(product_id, product_index)
5
	{
6
 
7
		var var_key = 'pv_' + product_id + "|";
8
		//alert('Länge: ' + wpsg_vp_vari[product_id].length);
9
 
10
		for (var i = 0; i < wpsg_vp_vari[product_id].length; i ++)
11
		{
12
 
13
			vkey1 = i + ":";
14
			vkey2 = '';
15
 
16
			if (wpsg_vp_vari[product_id][i] == "select")
17
			{
18
				vkey2 = jQuery('#wpsg_produktform_' + product_index + ' .wpsg_produkt_' + product_id + " #wpsg_vpfield_" + product_id + "_" + i).val();
19
			}
20
			else if (wpsg_vp_vari[product_id][i] == "radio")
21
			{
22
				vkey2 = jQuery('#wpsg_produktform_' + product_index + ' .wpsg_produkt_' + product_id + ' input[name="wpsg_vp[' + i + ']"]:checked').val();
23
			}
24
			else if (wpsg_vp_vari[product_id][i] == "checkbox")
25
			{
26
				vkey2 = jQuery('#wpsg_produktform_' + product_index + ' .wpsg_produkt_' + product_id + ' input[name="wpsg_vp[' + i + ']"]:checked').length;
27
			}
28
			else if (wpsg_vp_vari[product_id][i] == "image")
29
			{
30
				vkey2 = jQuery('#wpsg_produktform_' + product_index + ' .wpsg_produkt_' + product_id + ' .wpsg_mod_productvariants_imageselect_' + i + ' .akt').attr("data-wpsg-id");
31
			}
32
 
33
			if (vkey2 != '') {
34
				if (wpsg_vp_vari[product_id][i] == "image")
35
					jQuery('#wpsg_vp_' + i).val(vkey2);
36
				var_key += vkey1 + vkey2;
37
				if (i < (wpsg_vp_vari[product_id].length - 1)) var_key += "|";
38
			}
39
		}
40
 
41
		//console.log(jQuery('#wpsg_produktform_' + product_index).serialize());
42
		//console.log(var_key);
43
		//return;
44
 
45
		jQuery('#wpsg_produktform_' + product_index).append('<div class="wpsg_product_layer"><img src="' + wpsg_ajax.img_ajaxloading + '" alt="' + wpsg_ajax.label_pleasewait + '" /></div>');
46
 
47
		jQuery.ajax( {
48
			'url': wpsg_ajax.ajaxurl,
49
			'method': 'get',
50
			'data': {
51
				'action': 'wpsg_productvariants_switch',
52
				'wpsg_post_id': jQuery('#wpsg_produktform_' + product_index + ' input[name="wpsg_post_id"]').val(),
53
				'quantity': jQuery('#wpsg_menge_' + product_index).val(),
54
				'template': jQuery('#wpsg_produktform_' + product_index + ' input[name="wpsg[template]"]').val(),
55
				'referer': jQuery('#wpsg_produktform_' + product_index + ' input[name="myReferer"]').val(),
56
				'form_data': jQuery('#wpsg_produktform_' + product_index).serialize(),
57
				'product_key': var_key,
58
				'product_index': product_index
59
			},
60
			'success': function(data) {
61
 
62
				jQuery('#wpsg_produktform_' + product_index).replaceWith(data);
63
 
64
			}
65
		} );
66
 
67
	} // function wpsg_vp_switch(produkt_id)
68
 
5767 daniel 69
    function wpsg_mod_productvariants_reload(event)
70
    {
71
 
72
        var product_index = jQuery(event.target).parents('.wpsg_mod_productvariants_product_wrap').attr('wpsg-productindex');
73
 
74
        //jQuery('#wpsg_produktform_' + product_index).append('<div class="wpsg_product_layer"><img src="' + wpsg_ajax.img_ajaxloading + '" alt="' + wpsg_ajax.label_pleasewait + '" /></div>');
75
 
76
		jQuery.ajax( {
77
			'url': wpsg_ajax.ajaxurl,
78
			'method': 'get',
79
			'data': {
80
				'action': 'wpsg_productvariants_switch',
81
				'wpsg_post_id': jQuery('#wpsg_produktform_' + product_index + ' input[name="wpsg_post_id"]').val(),
82
				'form_data': jQuery('#wpsg_produktform_' + product_index).serialize(),
83
				'product_index': product_index
84
			},
85
			'success': function(data) {
86
 
87
				jQuery('#wpsg_produktform_' + product_index).replaceWith(data);
88
 
89
			}
90
		} );
91
 
92
    } // function wpsg_mod_productvariants_reload(event)