• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

wordpress function breaks wp-admin

phpwordpressfunctionwoocommerce


PHP Snippet 1:

function geo_client_currency( $client_currency ) {
    if ( WC()->customer ) {
        $country = WC()->customer->get_shipping_country();

        /**
         * Assuming more are going to be added otherwise a switch is overkill.
         * Short example: $client_currency = ( 'GB' === $country ) ? 'GBP' : 'EUR';
         */
        switch ( $country ) {
            case 'GB': 
                $client_currency = 'GBP'; 
                break;

            default: 
                $client_currency = 'EUR';
        }
    }

    return $client_currency;
}
add_filter( 'wcml_client_currency', 'geo_client_currency' );

Related Snippets

Display the WooCommerce product price inside a custom function

Last order would be re-order in wooCommerce. How is it possible?

google content api for shopping

Malformed MIME header error in Symfony 5.3

Call authenticate manually in router middleware

The difference when using if statement true === something() vs something() === true [duplicate]

zsh: command not found: php

Spam Filter in Contact Form

Correctly determine if date string is a valid date in that format

Laravel: Create morphs() relationship nullable

Laravel PHP: multiple project run at the same time [closed]

Laravel with App Engine Standard Class 'FacadeIgnitionIgnitionServiceProvider' not found

PHP SoapClient: set a namespace without prefix

Laravel: HTML in notification

PHP: Print caught exception like Xdebug

About Contact Privacy policy Terms and conditions