WOOCS - Sélecteur de devise WooCommerce

Modules complémentaires de produits WooCommerce (par WooCommerce)

L'URL du plugin: https://woocommerce.com/products/product-add-ons/

  • Dans le fichier \plugins\woocommerce-product-addons\includes\class-product-addon-cart.php ajouter le code suivant:
    if (class_exists('WOOCS')) { global $WOOCS; if ($WOOCS->is_multiple_allowed) { $currrent = $WOOCS->current_currency ; if ($currrent != $WOOCS->default_currency) { $currencies = $WOOCS->get_currencies(); $rate = $currencies[$current]['rate'] ; //$prix = $prix / $tarif ; } } }

  • ET ajoutez ce code :
    $price_temp = $addon['price'] ; if (class_exists('WOOCS')) { global $WOOCS; $currrent = $WOOCS->current_currency ; if ($currrent != $WOOCS->default_currency AND $WOOCS->is_multiple_allowed) { $currencies = $WOOCS->get_currencies(); $rate = $currencies[$current]['rate'] ; $price_temp = $price_temp * $rate ; } }

  • ET changer le code :
    if ($addon['price'] && 'percentage_based' !== $price_type && class_exists('WOOCS')) { global $WOOCS; $currrent = $WOOCS->current_currency ; if ($currrent != $WOOCS->default_currency AND $WOOCS->is_multiple_allowed) { $currencies = $WOOCS->get_currencies(); $rate = $currencies[$current]['rate'] ; $addon['price'] = $addon['price'] * $rate ; } }

  • Dans le fichier \wp-content\plugins\woocommerce-product-addons\includes\class-product-addon-display.php ajouter du code :
    $ suffixe = ''; //correction de woocs $woocs_is_multiple = 0; if (class_exists('WOOCS')) { global $WOOCS; $woocs_is_multiple = $WOOCS->is_multiple_allowed ; }
  • ET ajoutez le code : 'woocs_is_multiple' => $woocs_is_multiple
  • dans le fichier plugins\woocommerce-product-addons\assets\js\addons.js ajouter du code :
        var woocs_exists = true; try { if (woocs_current_currency) woocs_exists = true; } catch (e) { woocs_exists = false; } if (woocs_exists) { if (woocs_current_currency != undefined && woocs_current_currency['rate'] != undefined && woocommerce_addons_params.woocs_is_multiple == 0) { product_price = product_price * woocs_current_currency['rate']; } }

  • ET ajoutez ce code :
        var woocs_exists = true; try { if (woocs_current_currency) woocs_exists = true; } catch (e) { woocs_exists = false; } if (woocs_exists) { if (woocs_current_currency != undefined && woocs_current_currency['rate'] != undefined && addon_cost != undefined) { addon_data.cost = addon_data.cost * woocs_current_currency['rate']; addon_data.cost_raw = addon_data.cost_raw * woocs_current_currency['rate']; } }

  • Dans le fichier functions.php de votre thème wordpress actuel, ajoutez le code :
    add_filter('woocommerce_product_addons_option_price', 'woocs_compatib_woopd', 99990, 4); add_filter('woocommerce_product_addons_price', 'woocs_compatib_woopd', 99990, 4); function woocs_compatib_woopd($price, $option, $i, $type) { if ($option['price'] > 0 AND class_exists('WOOCS')) { global $WOOCS; $currrent = $WOOCS->current_currency ; if ($currrent != $WOOCS->default_currency AND $WOOCS->is_multiple_allowed) { $currencies = $WOOCS->get_currencies(); $rate = $currencies[$current]['rate'] ; $price = '(' . wc_price(WC_Product_Addons_Helper::get_product_addon_price_for_display($option['price'] * $rate)) . ')'; } } renvoie $prix; }