Changeset 953689
- Timestamp:
- 07/23/2014 07:55:10 PM (12 years ago)
- Location:
- woocommerce-chilean-peso-currency/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
woocommerce-chilean-peso.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-chilean-peso-currency/trunk/readme.txt
r795902 r953689 11 11 Tested up to: 3.6 12 12 13 Stable tag: 2. 4.113 Stable tag: 2.5 14 14 15 15 == Description == … … 30 30 == Changelog == 31 31 32 = 2.5 = 33 34 * Conexión a OpenExchange Rates para tener el valor del dolar actualizado. 35 * Se hace cache del valor del dolar para ahorrar consultas. 36 32 37 = 2.4 = 33 38 34 Se deshabilita el código postal como obligatorio.39 * Se deshabilita el código postal como obligatorio. 35 40 36 41 = 2.2 = 37 Agregada la posibilidad de usar paypal con woocommerce y chilean pesos.42 * Agregada la posibilidad de usar paypal con woocommerce y chilean pesos. 38 43 39 44 = 2.0 = 40 Added the Chilean states for WooCommerce41 Agregadas las Regiones de Chile a WooCommerce45 * Added the Chilean states for WooCommerce 46 * Agregadas las Regiones de Chile a WooCommerce -
woocommerce-chilean-peso-currency/trunk/woocommerce-chilean-peso.php
r795902 r953689 4 4 Plugin Name: WooCommerce Chilean Peso + Chilean States 5 5 Plugin URI: http://plugins.svn.wordpress.org/woocommerce-chilean-peso-currency/ 6 Description: This plugin add the chilean currency, symbol , paypal and thestates to WooCommerce.7 Version: 2. 4.16 Description: This plugin enables the payment with paypal for Chile and the Chilean states to WooCommerce. 7 Version: 2.5 8 8 Author: Cristian Tala Sánchez <cristian.tala@gmail.com> 9 9 Author URI: http://www.cristiantala.cl 10 10 License: GPLv3 11 11 Requires at least: 3.0 + 12 Tested up to: 3. 7.112 Tested up to: 3.9.1 13 13 */ 14 14 /* … … 32 32 33 33 function add_clp_currency($currencies) { 34 34 35 $currencies["CLP"] = 'Pesos Chilenos'; 35 36 return $currencies; … … 67 68 } 68 69 69 70 function add_clp_paypal_valid_currency( $currencies ) { 71 array_push ( $currencies , 'CLP' ); 72 return $currencies; 73 } 74 75 76 function convert_clp_to_usd($paypal_args){ 77 if ( $paypal_args['currency_code'] == 'CLP'){ 78 $convert_rate = 520; //set the converting rate 79 $paypal_args['currency_code'] = 'USD'; //change CLP to USD 80 $i = 1; 81 82 while (isset($paypal_args['amount_' . $i])) { 83 $paypal_args['amount_' . $i] = round( $paypal_args['amount_' . $i] / $convert_rate, 2); 84 ++$i; 85 } 86 87 } 88 return $paypal_args; 70 function add_clp_paypal_valid_currency($currencies) { 71 array_push($currencies, 'CLP'); 72 return $currencies; 89 73 } 90 74 75 /* 76 * Hace el cambio del valor a dolares a través de OpenExchange 77 * Se necesita tener curl instalado para que esto funcione. 78 */ 79 80 function convert_clp_to_usd($paypal_args) { 81 if ($paypal_args['currency_code'] == 'CLP') { 82 83 $valorDolar = wp_cache_get('clp_usd_ctala'); 84 if (false === $valorDolar) { 85 if (function_exists('curl_version')) { 86 $file = 'latest.json'; 87 $appId = '3d2f0769c4fc42278faffd3933a23dd6'; 88 $url = "http://openexchangerates.org/api/$file?app_id=$appId"; 89 // Open CURL session: 90 $ch = curl_init($url); 91 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 92 93 // Get the data: 94 $json = curl_exec($ch); 95 curl_close($ch); 96 97 // Decode JSON response: 98 $exchangeRates = json_decode($json); 99 $valorDolar = $exchangeRates->rates->CLP; 100 } else { 101 $valorDolar = 580; // Este es el valor por defecto. 102 } 103 wp_cache_set('clp_usd_ctala', $valorDolar); 104 } 105 106 $convert_rate = $valorDolar; //set the converting rate 107 $paypal_args['currency_code'] = 'USD'; //change CLP to USD 108 $i = 1; 109 110 while (isset($paypal_args['amount_' . $i])) { 111 $paypal_args['amount_' . $i] = round($paypal_args['amount_' . $i] / $convert_rate, 2); 112 ++$i; 113 } 114 } 115 return $paypal_args; 116 } 91 117 92 118 // Se eliminan los datos postales como obligatorios. 93 function postalcode_override_default_address_fields( $address_fields) {94 $address_fields['postcode']['required'] = false;119 function postalcode_override_default_address_fields($address_fields) { 120 $address_fields['postcode']['required'] = false; 95 121 96 return $address_fields;122 return $address_fields; 97 123 } 98 124 99 125 //Se eliminan los códigos portales como obligatorios. (Filtro) 100 add_filter( 'woocommerce_default_address_fields' , 'postalcode_override_default_address_fields');126 add_filter('woocommerce_default_address_fields', 'postalcode_override_default_address_fields'); 101 127 102 128 add_filter('woocommerce_paypal_args', 'convert_clp_to_usd'); … … 104 130 add_filter('woocommerce_currencies', 'add_clp_currency', 10, 1); 105 131 add_filter('woocommerce_currency_symbol', 'add_clp_currency_symbol', 10, 2); 106 add_filter( 'woocommerce_paypal_supported_currencies', 'add_clp_paypal_valid_currency' );132 add_filter('woocommerce_paypal_supported_currencies', 'add_clp_paypal_valid_currency'); 107 133 ?>
Note: See TracChangeset
for help on using the changeset viewer.