  |
94 | 94 | | |
| |
95 | 95 | | return false; |
| |
96 | 96 | | } |
  |
| 97 | + | |
| |
| 98 | + | static public function defineJavascript($products) { |
| |
| 99 | + | global $osC_Currencies; |
| |
| 100 | + | |
| |
| 101 | + | $string = '<script language="javascript" type="text/javascript">var combos = new Array();' . "\n"; |
| |
| 102 | + | |
| |
| 103 | + | foreach ( $products as $product_id => $product ) { |
| |
| 104 | + | $string .= 'combos[' . $product_id . '] = new Array();' . "\n" . |
| |
| 105 | + | 'combos[' . $product_id . '] = { price: "' . addslashes($osC_Currencies->displayPrice($product['data']['price'], $product['data']['tax_class_id'])) . '", model: "' . addslashes($product['data']['model']) . '", availability_shipping: ' . (int)$product['data']['availability_shipping'] . ', values: [] };' . "\n"; |
| |
| 106 | + | |
| |
| 107 | + | foreach ( $product['values'] as $group_id => $variants ) { |
| |
| 108 | + | $check_flag = false; |
| |
| 109 | + | |
| |
| 110 | + | foreach ( $variants as $variant ) { |
| |
| 111 | + | if ( !osC_Variants::hasCustomValue($variant['module']) ) { |
| |
| 112 | + | if ( $check_flag === false ) { |
| |
| 113 | + | $check_flag = true; |
| |
| 114 | + | |
| |
| 115 | + | $string .= 'combos[' . $product_id . ']["values"][' . $group_id . '] = new Array();' . "\n"; |
| |
| 116 | + | } |
| |
| 117 | + | |
| |
| 118 | + | $string .= 'combos[' . $product_id . ']["values"][' . $group_id . '][' . $variant['value_id'] . '] = ' . $variant['value_id'] . ';' . "\n"; |
| |
| 119 | + | } |
| |
| 120 | + | } |
| |
| 121 | + | } |
| |
| 122 | + | } |
| |
| 123 | + | |
| |
| 124 | + | $string .= '</script>'; |
| |
| 125 | + | |
| |
| 126 | + | return $string; |
| |
| 127 | + | } |
  |
97 | 128 | | } |
| |
98 | 129 | | ?> |