Z osebnim prevzemom:
/**
* @snippet Hide one shipping option in one zone when Free Shipping is available
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/?p=260
* @author Rodolfo Melogli
* @compatible WooCommerce 2.6.1
*/
addfilter( 'woocommercepackagerates', 'bbloomerunsetshippingwhenfreeisavailablein_zone', 10, 2 );
function bbloomerunsetshippingwhenfreeisavailableinzone( $rates, $package ) {
// Only unset rates if free_shipping is available
if ( isset( $rates['free_shipping:7'] ) ) {
unset( $rates['flat_rate:1'] );
}
return $rates;
}
/**
END OF HIDE SHIPPING
*/
PAYPAL HRK SUPPORT
/*PAYPAL HRK ENABLE */
/Step 1 Code to use HRK currency to display Dirhams in WooCommerce:/
addfilter( 'woocommercecurrencies', 'addhrkcurrency' );
function addhrkcurrency( $currencies ) {
$currencies['HRK'] = __( 'Croatian Kuna', 'woocommerce' );
return $currencies;
}
/Step 2 Code to add HRK currency symbol in WooCommerce:/
addfilter('woocommercecurrencysymbol', 'addhrkcurrencysymbol', 10, 2);
function addhrkcurrencysymbol( $currencysymbol, $currency ) {
switch( $currency ) {
case 'HRK': $currencysymbol = 'HRK'; break;
}
return $currencysymbol;
}
addfilter( 'woocommercepaypalsupportedcurrencies', 'addhrkpaypalvalidcurrency' );
function addhrkpaypalvalidcurrency( $currencies ) {
array_push ( $currencies , 'HRK' );
return $currencies;
}
/*Step 3 – Code to change 'AED' currency to ‘USD’ before checking out with Paypal through WooCommerce: */
addfilter('woocommercepaypalargs', 'converthrktoeur', 11 );
function getcurrency($fromCurrency='EUR', $toCurrency='HRK') {
$url = "http://www.google.com/finance/converter?a=1&from=$fromCurrency&to=$toCurrency";
$ch = curlinit();
$timeout = 0;
curlsetopt ($ch, CURLOPTURL, $url);
curlsetopt ($ch, CURLOPTRETURNTRANSFER, 1);
curlsetopt ($ch, CURLOPTUSERAGENT,
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
curlsetopt ($ch, CURLOPTCONNECTTIMEOUT, $timeout);
$rawdata = curlexec($ch);
curlclose($ch);
$data = explode('bld>', $rawdata);
$data = explode($toCurrency, $data[1]);
return round($data[0], 2);
}
function converthrktoeur($paypalargs){
if ( $paypalargs['currencycode'] == 'HRK'){
$convertrate = getcurrency(); //Set converting rate
$paypalargs['currencycode'] = 'EUR'; //change AED to USD
$i = 1;
while (isset($paypalargs['amount' . $i])) {
$paypalargs['amount' . $i] = round( $paypalargs['amount' . $i] / $convertrate, 2);
++$i;
}
if ( $paypalargs['shipping1'] > 0 ) {
$paypalargs['shipping1'] = round( $paypalargs['shipping1'] / $convertrate, 2);
}
if ( $paypalargs['discountamountcart'] > 0 ) {
$paypalargs['discountamountcart'] = round( $paypalargs['discountamountcart'] / $convertrate, 2);
}
if ( $paypalargs['taxcart'] > 0 ) {
$paypalargs['taxcart'] = round( $paypalargs['taxcart'] / $convertrate, 2);
}
}
return $paypal_args;
}
/* END OF HRK PAYPAL ENABLE */
skripte so iz neta, niso moje maslo. Pri prvi je treba dodat IDje šipingov.