//session_start(); global $site_langue; define('PLUGIN_CART_DIR',$_SERVER['DOCUMENT_ROOT'].'/plugins/cart'); include_once(PLUGIN_CART_DIR.'/classes/class.db.php'); include_once(PLUGIN_CART_DIR.'/php/plugincart.functions.php'); include_once(PLUGIN_CART_DIR.'/addons/mail/class.mail.php'); include_once(PLUGIN_CART_DIR.'/classes/class.plugincart.config.php'); include_once(PLUGIN_CART_DIR.'/classes/class.plugincart.php'); include_once(PLUGIN_CART_DIR.'/classes/class.plugincart.templates.php'); global $PLUGIN_DB, $PLUGIN_MAIL, $PLUGIN_CART, $PLUGIN_CART_TEMPLATES; $PLUGIN_MAIL = new PLUGIN_MAIL(); $PLUGIN_DB = new PLUGIN_DB(); $PLUGIN_CART = new PLUGIN_CART($site_langue); $PLUGIN_CART_TEMPLATES = new PLUGIN_CART_TEMPLATES(); // load wordpress fucntions file if($PLUGIN_CART->use_wordpress){ define('WP_USE_THEMES', false); require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); } $PLUGIN_CART->init(); ?> // $currency : ca|us // -> _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); } ?>