Merge pull request #17467 from woocommerce/fix/17460-currency
Add direction character to currency output
This commit is contained in:
commit
418bbbfee5
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -129,6 +129,10 @@
|
|||
.price {
|
||||
del {
|
||||
opacity: .5;
|
||||
display: inline-block;
|
||||
}
|
||||
ins {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -135,10 +135,12 @@ p.demo_store,
|
|||
ins {
|
||||
background: inherit;
|
||||
font-weight: 700;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
del {
|
||||
opacity: 0.5;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,12 +588,13 @@ p.demo_store,
|
|||
del {
|
||||
color: inherit;
|
||||
opacity: 0.5;
|
||||
display: block;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
ins {
|
||||
background: none;
|
||||
font-weight: 700;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.from {
|
||||
|
|
|
@ -224,10 +224,10 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
'default' => 'left',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'left' => __( 'Left', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . '99.99)',
|
||||
'right' => __( 'Right', 'woocommerce' ) . ' (99.99' . get_woocommerce_currency_symbol() . ')',
|
||||
'left_space' => __( 'Left with space', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ' 99.99)',
|
||||
'right_space' => __( 'Right with space', 'woocommerce' ) . ' (99.99 ' . get_woocommerce_currency_symbol() . ')',
|
||||
'left' => __( 'Left', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . '‎99.99)',
|
||||
'right' => __( 'Right', 'woocommerce' ) . ' (99.99' . get_woocommerce_currency_symbol() . '‏)',
|
||||
'left_space' => __( 'Left with space', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . '‎ 99.99)',
|
||||
'right_space' => __( 'Right with space', 'woocommerce' ) . ' (99.99 ' . get_woocommerce_currency_symbol() . '‏)',
|
||||
),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
|
|
@ -439,16 +439,16 @@ function get_woocommerce_price_format() {
|
|||
|
||||
switch ( $currency_pos ) {
|
||||
case 'left' :
|
||||
$format = '%1$s%2$s';
|
||||
$format = '%1$s‎%2$s';
|
||||
break;
|
||||
case 'right' :
|
||||
$format = '%2$s%1$s';
|
||||
$format = '%2$s%1$s‏';
|
||||
break;
|
||||
case 'left_space' :
|
||||
$format = '%1$s %2$s';
|
||||
$format = '%1$s‎ %2$s';
|
||||
break;
|
||||
case 'right_space' :
|
||||
$format = '%2$s %1$s';
|
||||
$format = '%2$s %1$s‏';
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -427,19 +427,19 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
|||
$currency_pos = get_option( 'woocommerce_currency_pos' );
|
||||
|
||||
// Default format (left).
|
||||
$this->assertEquals( '%1$s%2$s', get_woocommerce_price_format() );
|
||||
$this->assertEquals( '%1$s‎%2$s', get_woocommerce_price_format() );
|
||||
|
||||
// Right.
|
||||
update_option( 'woocommerce_currency_pos', 'right' );
|
||||
$this->assertEquals( '%2$s%1$s', get_woocommerce_price_format() );
|
||||
$this->assertEquals( '%2$s%1$s‏', get_woocommerce_price_format() );
|
||||
|
||||
// Left space.
|
||||
update_option( 'woocommerce_currency_pos', 'left_space' );
|
||||
$this->assertEquals( '%1$s %2$s', get_woocommerce_price_format() );
|
||||
$this->assertEquals( '%1$s‎ %2$s', get_woocommerce_price_format() );
|
||||
|
||||
// Right space.
|
||||
update_option( 'woocommerce_currency_pos', 'right_space' );
|
||||
$this->assertEquals( '%2$s %1$s', get_woocommerce_price_format() );
|
||||
$this->assertEquals( '%2$s %1$s‏', get_woocommerce_price_format() );
|
||||
|
||||
// Restore default.
|
||||
update_option( 'woocommerce_currency_pos', $currency_pos );
|
||||
|
@ -515,32 +515,32 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_wc_price() {
|
||||
// Common prices.
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1.00</span>', wc_price( 1 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1.10</span>', wc_price( 1.1 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1.17</span>', wc_price( 1.17 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</span>', wc_price( 1111.17 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>0.00</span>', wc_price( 0 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎1.00</span>', wc_price( 1 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎1.10</span>', wc_price( 1.1 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎1.17</span>', wc_price( 1.17 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎1,111.17</span>', wc_price( 1111.17 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎0.00</span>', wc_price( 0 ) );
|
||||
|
||||
// Different currency.
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>1,111.17</span>', wc_price( 1111.17, array( 'currency' => 'USD' ) ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>‎1,111.17</span>', wc_price( 1111.17, array( 'currency' => 'USD' ) ) );
|
||||
|
||||
// Negative price.
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount">-<span class="woocommerce-Price-currencySymbol">£</span>1.17</span>', wc_price( -1.17 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount">-<span class="woocommerce-Price-currencySymbol">£</span>‎1.17</span>', wc_price( -1.17 ) );
|
||||
|
||||
// Bogus prices.
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>0.00</span>', wc_price( null ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>0.00</span>', wc_price( 'Q' ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>0.00</span>', wc_price( 'ಠ_ಠ' ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎0.00</span>', wc_price( null ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎0.00</span>', wc_price( 'Q' ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎0.00</span>', wc_price( 'ಠ_ಠ' ) );
|
||||
|
||||
// Trim zeros.
|
||||
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1</span>', wc_price( 1.00 ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎1</span>', wc_price( 1.00 ) );
|
||||
remove_filter( 'woocommerce_price_trim_zeros', '__return_true' );
|
||||
|
||||
// Ex tax label.
|
||||
$calc_taxes = get_option( 'woocommerce_calc_taxes' );
|
||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>1,111.17</span> <small class="woocommerce-Price-taxLabel tax_label">(ex. VAT)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎1,111.17</span> <small class="woocommerce-Price-taxLabel tax_label">(ex. VAT)</small>', wc_price( '1111.17', array( 'ex_tax_label' => true ) ) );
|
||||
update_option( 'woocommerce_calc_taxes', $calc_taxes );
|
||||
}
|
||||
|
||||
|
@ -819,7 +819,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.3.0
|
||||
*/
|
||||
public function test_wc_format_sale_price() {
|
||||
$this->assertEquals( '<del><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>10.00</span></del> <ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>5.00</span></ins>', wc_format_sale_price( '10', '5' ) );
|
||||
$this->assertEquals( '<del><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎10.00</span></del> <ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎5.00</span></ins>', wc_format_sale_price( '10', '5' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -828,7 +828,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
|
|||
* @since 3.3.0
|
||||
*/
|
||||
public function test_wc_format_price_range() {
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>10.00</span> – <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>5.00</span>', wc_format_price_range( '10', '5' ) );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎10.00</span> – <span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>‎5.00</span>', wc_format_price_range( '10', '5' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -794,7 +794,7 @@ class WC_Tests_CRUD_Orders extends WC_Unit_Test_Case {
|
|||
$object = new WC_Order();
|
||||
$object->set_total( 100 );
|
||||
$object->set_currency( 'USD' );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>100.00</span>', $object->get_formatted_order_total() );
|
||||
$this->assertEquals( '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>‎100.00</span>', $object->get_formatted_order_total() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue