use_wordpress){ define('WP_USE_THEMES', false); require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); } $PLUGIN_CART->init(); ?> _switch_currency('ca'); // -> _switch_currency('us'); function _switch_currency($currency = false){ global $PLUGIN_DB, $PLUGIN_CART; if(!$currency){return false;} $old_cart = $PLUGIN_CART->_get_cart(); $new_product = array(); foreach($old_cart['Cart']['Products'] as $code => $produit){ if(is_numeric($produit['QUANTITY'])&&$produit['QUANTITY']+0==0){continue;} $where = array('ID' => $code); $where_arg = array('='); $reponse = req_mysql('S', 'produits_var', false, $where, $where_arg, false, false); if($datas = lire_data_mysql($reponse)){ // si produit trouver avec le code if($datas['Prix_'.$currency]){ $new_product[$code] = $produit; $prix = floatval($datas['Prix_'.$currency]); $new_product[$code]['PRICE'] = $prix; $new_product[$code]['SUBTOTAL'] = number_format($prix * $new_product[$code]['QUANTITY'],2); $new_product[$code]['DEFAULT_TAXABLE'] = $new_product[$code]['DEFAULT_TAXABLE'] ? $new_product[$code]['DEFAULT_TAXABLE'] : $new_product[$code]['TAXABLE']; if($currency=='us'){ $new_product[$code]['TAXABLE'] = false; }else{ $new_product[$code]['TAXABLE'] = $new_product[$code]['DEFAULT_TAXABLE']; } } } } $old_cart['Cart']['Products'] = $new_product; $PLUGIN_CART->_update_cart($new_product); } ?> Questions
Allez! Amusez-vous!