Merge pull request #29752 from woocommerce/fix/29730
Set USD as default store currency
This commit is contained in:
commit
aab56d84e0
|
@ -481,7 +481,7 @@ class WC_Admin_Setup_Wizard {
|
||||||
$state = WC()->countries->get_base_state();
|
$state = WC()->countries->get_base_state();
|
||||||
$country = WC()->countries->get_base_country();
|
$country = WC()->countries->get_base_country();
|
||||||
$postcode = WC()->countries->get_base_postcode();
|
$postcode = WC()->countries->get_base_postcode();
|
||||||
$currency = get_option( 'woocommerce_currency', 'GBP' );
|
$currency = get_option( 'woocommerce_currency', 'USD' );
|
||||||
$product_type = get_option( 'woocommerce_product_type', 'both' );
|
$product_type = get_option( 'woocommerce_product_type', 'both' );
|
||||||
$sell_in_person = get_option( 'woocommerce_sell_in_person', 'none_selected' );
|
$sell_in_person = get_option( 'woocommerce_sell_in_person', 'none_selected' );
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ class WC_Settings_General extends WC_Settings_Page {
|
||||||
'title' => __( 'Currency', 'woocommerce' ),
|
'title' => __( 'Currency', 'woocommerce' ),
|
||||||
'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
|
'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
|
||||||
'id' => 'woocommerce_currency',
|
'id' => 'woocommerce_currency',
|
||||||
'default' => 'GBP',
|
'default' => 'USD',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'class' => 'wc-enhanced-select',
|
'class' => 'wc-enhanced-select',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
|
|
|
@ -593,32 +593,32 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
||||||
*/
|
*/
|
||||||
public function test_wc_price() {
|
public function test_wc_price() {
|
||||||
// Common prices.
|
// Common prices.
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1.00</bdi></span>', wc_price( 1 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1.00</bdi></span>', wc_price( 1 ) );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1.10</bdi></span>', wc_price( 1.1 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1.10</bdi></span>', wc_price( 1.1 ) );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1.17</bdi></span>', wc_price( 1.17 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1.17</bdi></span>', wc_price( 1.17 ) );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</bdi></span>', wc_price( 1111.17 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1,111.17</bdi></span>', wc_price( 1111.17 ) );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>0.00</bdi></span>', wc_price( 0 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>0.00</bdi></span>', wc_price( 0 ) );
|
||||||
|
|
||||||
// Different currency.
|
// Different currency.
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1,111.17</bdi></span>', wc_price( 1111.17, array( 'currency' => 'USD' ) ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</bdi></span>', wc_price( 1111.17, array( 'currency' => 'GBP' ) ) );
|
||||||
|
|
||||||
// Negative price.
|
// Negative price.
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi>-<span class="woocommerce-Price-currencySymbol">£</span>1.17</bdi></span>', wc_price( -1.17 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi>-<span class="woocommerce-Price-currencySymbol">$</span>1.17</bdi></span>', wc_price( -1.17 ) );
|
||||||
|
|
||||||
// Bogus prices.
|
// Bogus prices.
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>0.00</bdi></span>', wc_price( null ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>0.00</bdi></span>', wc_price( null ) );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>0.00</bdi></span>', wc_price( 'Q' ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>0.00</bdi></span>', wc_price( 'Q' ) );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>0.00</bdi></span>', wc_price( 'ಠ_ಠ' ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>0.00</bdi></span>', wc_price( 'ಠ_ಠ' ) );
|
||||||
|
|
||||||
// Trim zeros.
|
// Trim zeros.
|
||||||
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
|
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1</bdi></span>', wc_price( 1.00 ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1</bdi></span>', wc_price( 1.00 ) );
|
||||||
remove_filter( 'woocommerce_price_trim_zeros', '__return_true' );
|
remove_filter( 'woocommerce_price_trim_zeros', '__return_true' );
|
||||||
|
|
||||||
// Ex tax label.
|
// Ex tax label.
|
||||||
$calc_taxes = get_option( 'woocommerce_calc_taxes' );
|
$calc_taxes = get_option( 'woocommerce_calc_taxes' );
|
||||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</bdi></span> <small class="woocommerce-Price-taxLabel tax_label">(ex. tax)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>1,111.17</bdi></span> <small class="woocommerce-Price-taxLabel tax_label">(ex. tax)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
|
||||||
update_option( 'woocommerce_calc_taxes', $calc_taxes );
|
update_option( 'woocommerce_calc_taxes', $calc_taxes );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
*/
|
*/
|
||||||
public function test_wc_format_sale_price() {
|
public function test_wc_format_sale_price() {
|
||||||
$this->assertEquals( '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>10.00</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>5.00</bdi></span></ins>', wc_format_sale_price( '10', '5' ) );
|
$this->assertEquals( '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>10.00</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>5.00</bdi></span></ins>', wc_format_sale_price( '10', '5' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -935,7 +935,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
||||||
* @since 3.3.0
|
* @since 3.3.0
|
||||||
*/
|
*/
|
||||||
public function test_wc_format_price_range() {
|
public function test_wc_format_price_range() {
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>10.00</bdi></span> – <span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>5.00</bdi></span>', wc_format_price_range( '10', '5' ) );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>10.00</bdi></span> – <span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>5.00</bdi></span>', wc_format_price_range( '10', '5' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -259,15 +259,15 @@ class WC_Tests_Product_Data extends WC_Unit_Test_Case {
|
||||||
|
|
||||||
$product = wc_get_product( $product1_id );
|
$product = wc_get_product( $product1_id );
|
||||||
$this->assertEquals( $product1_id, $product->get_id() );
|
$this->assertEquals( $product1_id, $product->get_id() );
|
||||||
$this->assertEquals( '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>10.00</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>7.00</bdi></span></ins>', $product->get_price_html() );
|
$this->assertEquals( '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>10.00</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>7.00</bdi></span></ins>', $product->get_price_html() );
|
||||||
|
|
||||||
$product = wc_get_product( $product2_id );
|
$product = wc_get_product( $product2_id );
|
||||||
$this->assertEquals( $product2_id, $product->get_id() );
|
$this->assertEquals( $product2_id, $product->get_id() );
|
||||||
$this->assertEquals( '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>20.00</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>16.00</bdi></span></ins>', $product->get_price_html() );
|
$this->assertEquals( '<del aria-hidden="true"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>20.00</bdi></span></del> <ins><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>16.00</bdi></span></ins>', $product->get_price_html() );
|
||||||
|
|
||||||
$product = wc_get_product( $product3_id );
|
$product = wc_get_product( $product3_id );
|
||||||
$this->assertEquals( $product3_id, $product->get_id() );
|
$this->assertEquals( $product3_id, $product->get_id() );
|
||||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>50.00</bdi></span>', $product->get_price_html() );
|
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>50.00</bdi></span>', $product->get_price_html() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,7 +30,7 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
|
||||||
*/
|
*/
|
||||||
public function test_get_woocommerce_currency() {
|
public function test_get_woocommerce_currency() {
|
||||||
|
|
||||||
$this->assertEquals( 'GBP', get_woocommerce_currency() );
|
$this->assertEquals( 'USD', get_woocommerce_currency() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,10 +222,10 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
|
||||||
public function test_get_woocommerce_currency_symbol() {
|
public function test_get_woocommerce_currency_symbol() {
|
||||||
|
|
||||||
// Default currency.
|
// Default currency.
|
||||||
$this->assertEquals( '£', get_woocommerce_currency_symbol() );
|
$this->assertEquals( '$', get_woocommerce_currency_symbol() );
|
||||||
|
|
||||||
// Given specific currency.
|
// Given specific currency.
|
||||||
$this->assertEquals( '$', get_woocommerce_currency_symbol( 'USD' ) );
|
$this->assertEquals( '£', get_woocommerce_currency_symbol( 'GBP' ) );
|
||||||
|
|
||||||
// Each case.
|
// Each case.
|
||||||
foreach ( array_keys( get_woocommerce_currencies() ) as $currency_code ) {
|
foreach ( array_keys( get_woocommerce_currencies() ) as $currency_code ) {
|
||||||
|
|
Loading…
Reference in New Issue