Merge branch 'master' into pr/23043

This commit is contained in:
Gerhard 2019-07-10 10:34:52 +02:00
commit 98c24b1090
61 changed files with 810 additions and 27988 deletions

3
.gitignore vendored
View File

@ -53,3 +53,6 @@ contributors.md
# Screenshots for e2e tests failures
/screenshots/
# Language files
i18n/languages/woocommerce.pot

View File

@ -1,3 +1,4 @@
/* stylelint-disable no-descending-specificity */
body {
margin: 65px auto 24px;
box-shadow: none;
@ -27,6 +28,14 @@ body {
.hidden {
display: none;
}
#tiptip_content {
background: #5f6973;
}
#tiptip_holder.tip_top #tiptip_arrow_inner {
border-top-color: #5f6973;
}
}
.wc-setup-content {
@ -53,13 +62,13 @@ body {
p {
margin: 20px 0;
font-size: 1em;
line-height: 1.75em;
line-height: 1.75;
color: #666;
}
table {
font-size: 1em;
line-height: 1.75em;
line-height: 1.75;
color: #666;
}
@ -77,7 +86,7 @@ body {
th {
width: 35%;
vertical-align: top;
font-weight: normal;
font-weight: 400;
}
td {
@ -94,7 +103,7 @@ body {
}
.description {
line-height: 1.5em;
line-height: 1.5;
display: block;
margin-top: 0.25em;
color: #999;
@ -167,7 +176,7 @@ body {
&::before {
content: "\f333";
font-family: "dashicons";
font-family: dashicons; /* stylelint-disable-line font-family-no-missing-generic-family-keyword */
}
}
@ -178,7 +187,7 @@ body {
.add {
padding: 1em 0 0 1em;
line-height: 1em;
line-height: 1;
font-size: 1em;
width: 0;
margin: 6px 0 0;
@ -189,7 +198,7 @@ body {
&::before {
content: "\f502";
font-family: "dashicons";
font-family: dashicons; /* stylelint-disable-line font-family-no-missing-generic-family-keyword */
position: absolute;
left: 0;
top: 0;
@ -198,7 +207,7 @@ body {
.remove {
padding: 1em 0 0 1em;
line-height: 1em;
line-height: 1;
font-size: 1em;
width: 0;
margin: 0;
@ -209,7 +218,7 @@ body {
&::before {
content: "\f182";
font-family: "dashicons";
font-family: dashicons; /* stylelint-disable-line font-family-no-missing-generic-family-keyword */
position: absolute;
left: 0;
top: 0;
@ -227,7 +236,7 @@ body {
.page-name {
width: 30%;
font-weight: bold;
font-weight: 700;
}
th,
@ -249,14 +258,14 @@ body {
p {
color: #777;
margin: 6px 0 0 24px;
line-height: 1.75em;
line-height: 1.75;
input {
vertical-align: middle;
margin: 1px 0 0;
height: 1.75em;
width: 1.75em;
line-height: 1.75em;
line-height: 1.75;
}
label {
@ -324,7 +333,7 @@ body {
text-shadow: 1px 0 1px #eee, 0 1px 1px #eee;
font-size: 1em;
height: auto;
line-height: 1.75em;
line-height: 1.75;
margin: 0 0 0.75em;
opacity: 1;
padding: 1em;
@ -358,7 +367,7 @@ body {
li a::before {
color: #82878c;
font: normal 20px/1 "dashicons";
font: 400 20px/1 dashicons; /* stylelint-disable-line font-family-no-missing-generic-family-keyword */
speak: none;
display: inline-block;
padding: 0 10px 0 0;
@ -409,7 +418,7 @@ body {
p {
font-size: 14px;
line-height: 1.5em;
line-height: 1.5;
}
.checkbox {
@ -499,7 +508,7 @@ body {
text-align: center;
position: relative;
border-bottom: 4px solid #ccc;
line-height: 1.4em;
line-height: 1.4;
a {
color: #a16696;
@ -534,7 +543,7 @@ body {
li.active {
border-color: #a16696;
color: #a16696;
font-weight: bold;
font-weight: 700;
&::before {
border-color: #a16696;
@ -557,16 +566,6 @@ body {
margin: 20px 0 0;
position: relative;
.button {
font-size: 1.25em;
padding: 0.5em 1em;
line-height: 1em;
margin-right: 0.5em;
margin-bottom: 2px;
height: auto;
border-radius: 4px;
}
.button-primary {
background-color: #bb77ae;
border-color: #a36597;
@ -681,7 +680,7 @@ body {
margin: 0 0 1em 0;
padding: 0;
font-size: 1em;
line-height: 1.5em;
line-height: 1.5;
}
}
@ -707,7 +706,7 @@ body {
flex-basis: 0;
min-width: 160px;
text-align: center;
font-weight: bold;
font-weight: 700;
padding: 2em 0;
align-self: stretch;
display: flex;
@ -790,7 +789,7 @@ body {
border-radius: 10em;
position: relative;
input[type=checkbox] {
input[type="checkbox"] {
display: none;
}
@ -850,8 +849,7 @@ body {
.wc-wizard-service-enable::before {
content: "\f343"; // up chevron
font-family: "dashicons";
visibility: initial;
font-family: dashicons; /* stylelint-disable-line font-family-no-missing-generic-family-keyword */
color: #666;
font-size: 25px;
margin-top: -7px;
@ -882,7 +880,7 @@ body {
margin: 0;
.wc-wizard-service-name {
font-weight: normal;
font-weight: 400;
text-align: left;
align-items: center;
max-height: 5em;
@ -966,7 +964,7 @@ body {
.wc-setup-shipping-units {
p {
line-height: 1.5em;
line-height: 1.5;
font-size: 13px;
margin-bottom: 0.25em;
text-align: center;
@ -1021,7 +1019,7 @@ body {
p.wc-wizard-feature-name,
p.wc-wizard-feature-description {
margin: 0;
line-height: 1.5em;
line-height: 1.5;
}
}
@ -1061,8 +1059,12 @@ h3.jetpack-reasons {
padding: 1em 2em;
box-shadow: none;
min-width: 12em;
min-width: auto;
margin-top: 10px;
line-height: 1;
margin-right: 0.5em;
margin-bottom: 2px;
height: auto;
border-radius: 4px;
&:focus,
&:hover,
@ -1076,7 +1078,7 @@ h3.jetpack-reasons {
font-style: italic;
color: #999;
font-size: 14px;
line-height: 1.5em;
line-height: 1.5;
margin: 5px 0;
& > * {
@ -1292,10 +1294,6 @@ h3.jetpack-reasons {
font-size: 15px;
margin: 1em 0 1em 1.5em;
}
.button::last-child {
margin-right: 1.5em;
}
}
}
}
@ -1312,7 +1310,7 @@ p.jetpack-terms {
text-align: center;
max-width: 480px;
margin: 0 auto;
line-height: 1.5em;
line-height: 1.5;
}
.woocommerce-error {
@ -1461,14 +1459,14 @@ p.jetpack-terms {
h3 {
font-size: 15px;
font-weight: bold;
font-weight: 700;
letter-spacing: 0.5px;
margin-bottom: 0;
}
p {
margin-top: 0;
line-height: 1.5em;
line-height: 1.5;
}
}
}
@ -1482,23 +1480,6 @@ p.jetpack-terms {
text-decoration: underline dotted;
}
.wc-setup {
#tiptip_content {
background: #5f6973;
}
#tiptip_holder.tip_top #tiptip_arrow_inner {
border-top-color: #5f6973;
}
}
.wc-setup-shipping-recommended {
border-bottom: 1px solid #eee;
margin-top: 0;
padding: 30px 0;
}
@media only screen and (max-width: 400px) {
#wc-logo img {
@ -1574,3 +1555,4 @@ p.jetpack-terms {
}
}
}
/* stylelint-enable */

View File

@ -1,3 +1,4 @@
/* global woocommerce_admin_meta_boxes_coupon */
jQuery(function( $ ) {
/**
@ -12,6 +13,9 @@ jQuery(function( $ ) {
$( 'select#discount_type' )
.on( 'change', this.type_options )
.change();
this.insert_generate_coupon_code_button();
$( '.button.generate-coupon-code' ).on( 'click', this.generate_coupon_code );
},
/**
@ -32,6 +36,33 @@ jQuery(function( $ ) {
} else {
$( '.limit_usage_to_x_items_field' ).hide();
}
},
/**
* Insert generate coupon code buttom HTML.
*/
insert_generate_coupon_code_button: function() {
$( '.post-type-shop_coupon' ).find( '#title' ).after(
'<a href="#" class="button generate-coupon-code">' + woocommerce_admin_meta_boxes_coupon.generate_button_text + '</a>'
);
},
/**
* Generate a random coupon code
*/
generate_coupon_code: function( e ) {
e.preventDefault();
var $coupon_code_field = $( '#title' ),
$coupon_code_label = $( '#title-prompt-text' ),
$result = '';
for ( var i = 0; i < woocommerce_admin_meta_boxes_coupon.char_length; i++ ) {
$result += woocommerce_admin_meta_boxes_coupon.characters.charAt(
Math.floor( Math.random() * woocommerce_admin_meta_boxes_coupon.characters.length )
);
}
$result = woocommerce_admin_meta_boxes_coupon.prefix + $result + woocommerce_admin_meta_boxes_coupon.suffix;
$coupon_code_field.focus().val( $result );
$coupon_code_label.addClass( 'screen-reader-text' );
}
};

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
/**
* Load assets
*
* @package WooCommerce/Admin
* @version 2.1.0
* @package WooCommerce/Admin
* @version 3.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -275,6 +275,17 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
}
if ( in_array( $screen_id, array( 'shop_coupon', 'edit-shop_coupon' ) ) ) {
wp_enqueue_script( 'wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array( 'wc-admin-meta-boxes' ), WC_VERSION );
wp_localize_script(
'wc-admin-coupon-meta-boxes',
'woocommerce_admin_meta_boxes_coupon',
array(
'generate_button_text' => esc_html__( 'Generate coupon code', 'woocommerce' ),
'characters' => apply_filters( 'woocommerce_coupon_code_generator_characters', 'ABCDEFGHJKMNPQRSTUVWXYZ23456789' ),
'char_length' => apply_filters( 'woocommerce_coupon_code_generator_character_length', 8 ),
'prefix' => apply_filters( 'woocommerce_coupon_code_generator_prefix', '' ),
'suffix' => apply_filters( 'woocommerce_coupon_code_generator_suffix', '' ),
)
);
}
if ( in_array( str_replace( 'edit-', '', $screen_id ), array_merge( array( 'shop_coupon', 'product' ), wc_get_order_types( 'order-meta-boxes' ) ) ) ) {
$post_id = isset( $post->ID ) ? $post->ID : '';

View File

@ -44,6 +44,9 @@ class WC_Admin_Menus {
if ( apply_filters( 'woocommerce_show_admin_bar_visit_store', true ) ) {
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 31 );
}
// Handle saving settings earlier than load-{page} hook to avoid race conditions in conditional menus.
add_action( 'wp_loaded', array( $this, 'save_settings' ) );
}
/**
@ -85,14 +88,40 @@ class WC_Admin_Menus {
* Loads gateways and shipping methods into memory for use within settings.
*/
public function settings_page_init() {
global $current_tab, $current_section;
WC()->payment_gateways();
WC()->shipping();
// Include settings pages.
WC_Admin_Settings::get_settings_pages();
// Add any posted messages.
if ( ! empty( $_GET['wc_error'] ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['wc_error'] ) ) ); // WPCS: input var okay, CSRF ok.
}
if ( ! empty( $_GET['wc_message'] ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['wc_message'] ) ) ); // WPCS: input var okay, CSRF ok.
}
do_action( 'woocommerce_settings_page_init' );
}
/**
* Handle saving of settings.
*
* @return void
*/
public function save_settings() {
global $current_tab, $current_section;
// We should only save on the settings page.
if ( ! is_admin() || ! isset( $_GET['page'] ) || 'wc-settings' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
return;
}
// Include settings pages.
WC_Admin_Settings::get_settings_pages();
// Get current tab/section.
$current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_title( wp_unslash( $_GET['tab'] ) ); // WPCS: input var okay, CSRF ok.
$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); // WPCS: input var okay, CSRF ok.
@ -103,17 +132,6 @@ class WC_Admin_Menus {
} elseif ( '' === $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST['save'] ) ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::save();
}
// Add any posted messages.
if ( ! empty( $_GET['wc_error'] ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::add_error( wp_kses_post( wp_unslash( $_GET['wc_error'] ) ) ); // WPCS: input var okay, CSRF ok.
}
if ( ! empty( $_GET['wc_message'] ) ) { // WPCS: input var okay, CSRF ok.
WC_Admin_Settings::add_message( wp_kses_post( wp_unslash( $_GET['wc_message'] ) ) ); // WPCS: input var okay, CSRF ok.
}
do_action( 'woocommerce_settings_page_init' );
}
/**

View File

@ -929,6 +929,41 @@ class WC_Admin_Setup_Wizard {
<p><?php echo wp_kses_post( $intro_text ); ?></p>
<?php endif; ?>
<form method="post">
<?php if ( $is_wcs_labels_supported || $is_shipstation_supported ) : ?>
<ul class="wc-setup-shipping-recommended">
<?php
if ( $is_wcs_labels_supported ) :
$this->display_recommended_item(
array(
'type' => 'woocommerce_services',
'title' => __( 'Did you know you can print shipping labels at home?', 'woocommerce' ),
'description' => __( 'Use WooCommerce Shipping (powered by WooCommerce Services & Jetpack) to save time at the post office by printing your shipping labels at home.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-services-icon.png',
'img_alt' => __( 'WooCommerce Services icon', 'woocommerce' ),
'plugins' => $this->get_wcs_requisite_plugins(),
)
);
elseif ( $is_shipstation_supported ) :
$this->display_recommended_item(
array(
'type' => 'shipstation',
'title' => __( 'Did you know you can print shipping labels at home?', 'woocommerce' ),
'description' => __( 'We recommend using ShipStation to save time at the post office by printing your shipping labels at home. Try ShipStation free for 30 days.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-shipstation-icon.png',
'img_alt' => __( 'ShipStation icon', 'woocommerce' ),
'plugins' => array(
array(
'name' => __( 'ShipStation', 'woocommerce' ),
'slug' => 'woocommerce-shipstation-integration',
),
),
)
);
endif;
?>
</ul>
<?php endif; ?>
<?php if ( empty( $existing_zones ) ) : ?>
<ul class="wc-wizard-services shipping">
<li class="wc-wizard-service-item">
@ -994,41 +1029,6 @@ class WC_Admin_Setup_Wizard {
</ul>
<?php endif; ?>
<?php if ( $is_wcs_labels_supported || $is_shipstation_supported ) : ?>
<ul class="wc-setup-shipping-recommended">
<?php
if ( $is_wcs_labels_supported ) :
$this->display_recommended_item(
array(
'type' => 'woocommerce_services',
'title' => __( 'Print shipping labels at home', 'woocommerce' ),
'description' => __( 'We recommend WooCommerce Services & Jetpack. These plugins will save you time at the Post Office by enabling you to print your shipping labels at home.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-services-icon.png',
'img_alt' => __( 'WooCommerce Services icon', 'woocommerce' ),
'plugins' => $this->get_wcs_requisite_plugins(),
)
);
elseif ( $is_shipstation_supported ) :
$this->display_recommended_item(
array(
'type' => 'shipstation',
'title' => __( 'Print shipping labels at home', 'woocommerce' ),
'description' => __( 'We recommend using ShipStation to save time at the Post Office by printing your shipping labels at home. Try ShipStation free for 30 days.', 'woocommerce' ),
'img_url' => WC()->plugin_url() . '/assets/images/obw-shipstation-icon.png',
'img_alt' => __( 'ShipStation icon', 'woocommerce' ),
'plugins' => array(
array(
'name' => __( 'ShipStation', 'woocommerce' ),
'slug' => 'woocommerce-shipstation-integration',
),
),
)
);
endif;
endif;
?>
</ul>
<div class="wc-setup-shipping-units">
<p>
<?php

View File

@ -140,7 +140,7 @@ class WC_Settings_Tax extends WC_Settings_Page {
* @return null
*/
public function save_tax_classes( $raw_tax_classes ) {
$tax_classes = array_map( 'trim', explode( "\n", $raw_tax_classes ) );
$tax_classes = array_filter( array_map( 'trim', explode( "\n", $raw_tax_classes ) ) );
$existing_tax_classes = WC_Tax::get_tax_classes();
$removed = array_diff( $existing_tax_classes, $tax_classes );
$added = array_diff( $tax_classes, $existing_tax_classes );

View File

@ -464,7 +464,7 @@ final class WC_Cart_Totals {
$new_taxes = WC_Tax::calc_tax( $item->price - array_sum( $taxes ), $item->tax_rates, false );
// Now we have a new item price.
$item->price = round( $item->price - array_sum( $taxes ) + array_sum( $new_taxes ) );
$item->price = $item->price - array_sum( $taxes ) + array_sum( $new_taxes );
}
}
return $item;

View File

@ -359,7 +359,7 @@ class WC_Discounts {
$discounted_price = $this->get_discounted_price_in_cents( $item );
// Get the price we actually want to discount, based on settings.
$price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : $item->price;
$price_to_discount = ( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ) ? $discounted_price : round( $item->price );
// See how many and what price to apply to.
$apply_quantity = $limit_usage_qty && ( $limit_usage_qty - $applied_count ) < $item->quantity ? $limit_usage_qty - $applied_count : $item->quantity;

View File

@ -258,8 +258,8 @@ class WC_Install {
WC()->wpdb_table_fix();
self::remove_admin_notices();
self::create_options();
self::create_tables();
self::create_options();
self::create_roles();
self::setup_environment();
self::create_terms();
@ -525,6 +525,10 @@ class WC_Install {
add_option( 'woocommerce_thumbnail_image_width', '300', '', 'yes' );
add_option( 'woocommerce_checkout_highlight_required_fields', 'yes', '', 'yes' );
add_option( 'woocommerce_demo_store', 'no', '', 'no' );
// Define initial tax classes.
WC_Tax::create_tax_class( __( 'Reduced rate', 'woocommerce' ) );
WC_Tax::create_tax_class( __( 'Zero rate', 'woocommerce' ) );
}
/**
@ -699,6 +703,13 @@ class WC_Install {
$collate = $wpdb->get_charset_collate();
}
/*
* Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that.
* As of WP 4.2, however, they moved to utf8mb4, which uses 4 bytes per character. This means that an index which
* used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters.
*/
$max_index_length = 191;
$tables = "
CREATE TABLE {$wpdb->prefix}woocommerce_sessions (
session_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
@ -899,7 +910,7 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes (
name varchar(200) NOT NULL DEFAULT '',
slug varchar(200) NOT NULL DEFAULT '',
PRIMARY KEY (tax_rate_class_id),
UNIQUE KEY slug (slug)
UNIQUE KEY slug (slug($max_index_length))
) $collate;
";
@ -918,6 +929,7 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes (
$tables = array(
"{$wpdb->prefix}wc_download_log",
"{$wpdb->prefix}wc_product_meta_lookup",
"{$wpdb->prefix}wc_tax_rate_classes",
"{$wpdb->prefix}wc_webhooks",
"{$wpdb->prefix}woocommerce_api_keys",
"{$wpdb->prefix}woocommerce_attribute_taxonomies",

View File

@ -763,6 +763,10 @@ class WC_Tax {
public static function create_tax_class( $name, $slug = '' ) {
global $wpdb;
if ( empty( $name ) ) {
return new WP_Error( 'tax_class_invalid_name', __( 'Tax class requires a valid name', 'woocommerce' ) );
}
$existing = self::get_tax_classes();
$existing_slugs = self::get_tax_class_slugs();

View File

@ -569,7 +569,13 @@ final class WooCommerce {
* - WP_LANG_DIR/plugins/woocommerce-LOCALE.mo
*/
public function load_plugin_textdomain() {
$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
if ( function_exists( 'determine_locale' ) ) {
$locale = determine_locale();
} else {
// @todo Remove when start supporting WP 5.0 or later.
$locale = is_admin() ? get_user_locale() : get_locale();
}
$locale = apply_filters( 'plugin_locale', $locale, 'woocommerce' );
unload_textdomain( 'woocommerce' );

View File

@ -249,24 +249,23 @@ class WC_Gateway_Paypal_Request {
*/
protected function get_shipping_args( $order ) {
$shipping_args = array();
if ( 'yes' === $this->gateway->get_option( 'send_shipping' ) ) {
if ( $order->needs_shipping_address() ) {
$shipping_args['address_override'] = $this->gateway->get_option( 'address_override' ) === 'yes' ? 1 : 0;
$shipping_args['no_shipping'] = 0;
// If we are sending shipping, send shipping address instead of billing.
$shipping_args['first_name'] = $this->limit_length( $order->get_shipping_first_name(), 32 );
$shipping_args['last_name'] = $this->limit_length( $order->get_shipping_last_name(), 64 );
$shipping_args['address1'] = $this->limit_length( $order->get_shipping_address_1(), 100 );
$shipping_args['address2'] = $this->limit_length( $order->get_shipping_address_2(), 100 );
$shipping_args['city'] = $this->limit_length( $order->get_shipping_city(), 40 );
$shipping_args['state'] = $this->get_paypal_state( $order->get_shipping_country(), $order->get_shipping_state() );
$shipping_args['country'] = $this->limit_length( $order->get_shipping_country(), 2 );
$shipping_args['zip'] = $this->limit_length( wc_format_postcode( $order->get_shipping_postcode(), $order->get_shipping_country() ), 32 );
if ( 'yes' === $this->gateway->get_option( 'send_shipping' ) ) {
// If we are sending shipping, send shipping address instead of billing.
$shipping_args['first_name'] = $this->limit_length( $order->get_shipping_first_name(), 32 );
$shipping_args['last_name'] = $this->limit_length( $order->get_shipping_last_name(), 64 );
$shipping_args['address1'] = $this->limit_length( $order->get_shipping_address_1(), 100 );
$shipping_args['address2'] = $this->limit_length( $order->get_shipping_address_2(), 100 );
$shipping_args['city'] = $this->limit_length( $order->get_shipping_city(), 40 );
$shipping_args['state'] = $this->get_paypal_state( $order->get_shipping_country(), $order->get_shipping_state() );
$shipping_args['country'] = $this->limit_length( $order->get_shipping_country(), 2 );
$shipping_args['zip'] = $this->limit_length( wc_format_postcode( $order->get_shipping_postcode(), $order->get_shipping_country() ), 32 );
}
} else {
$shipping_args['no_shipping'] = 1;
}
return $shipping_args;
}

View File

@ -1067,7 +1067,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
continue;
}
if ( $update_existing && ( $id || $sku ) && ! $id_exists && ! $sku_exists ) {
if ( $update_existing && ( isset( $parsed_data['id'] ) || isset( $parsed_data['sku'] ) ) && ! $id_exists && ! $sku_exists ) {
$data['skipped'][] = new WP_Error(
'woocommerce_product_importer_error',
esc_html__( 'No matching product exists to update.', 'woocommerce' ),

View File

@ -125,6 +125,7 @@ class WC_Shortcode_Products {
'terms' => '', // Comma separated term slugs or ids.
'terms_operator' => 'IN', // Operator to compare terms. Possible values are 'IN', 'NOT IN', 'AND'.
'tag' => '', // Comma separated tag slugs.
'tag_operator' => 'IN', // Operator to compare tags. Possible values are 'IN', 'NOT IN', 'AND'.
'visibility' => 'visible', // Product visibility setting. Possible values are 'visible', 'catalog', 'search', 'hidden'.
'class' => '', // HTML class.
'page' => 1, // Page for pagination.
@ -369,7 +370,7 @@ class WC_Shortcode_Products {
'taxonomy' => 'product_tag',
'terms' => array_map( 'sanitize_title', explode( ',', $this->attributes['tag'] ) ),
'field' => 'slug',
'operator' => 'IN',
'operator' => $this->attributes['tag_operator'],
);
}
}

View File

@ -10,22 +10,31 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates/Auth
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
?>
<?php do_action( 'woocommerce_auth_page_header' ); ?>
<h1><?php printf( __( '%s would like to connect to your store', 'woocommerce' ), esc_html( $app_name ) ); ?></h1>
<h1>
<?php
/* Translators: %s App name. */
printf( esc_html__( '%s would like to connect to your store', 'woocommerce' ), esc_html( $app_name ) );
?>
</h1>
<?php wc_print_notices(); ?>
<p><?php printf( __( 'This will give "%1$s" %2$s access which will allow it to:', 'woocommerce' ), '<strong>' . esc_html( $app_name ) . '</strong>', '<strong>' . esc_html( $scope ) . '</strong>' ); ?></p>
<p>
<?php
/* Translators: %1$s App name, %2$s scope. */
printf( esc_html__( 'This will give "%1$s" %2$s access which will allow it to:', 'woocommerce' ), '<strong>' . esc_html( $app_name ) . '</strong>', '<strong>' . esc_html( $scope ) . '</strong>' );
?>
</p>
<ul class="wc-auth-permissions">
<?php foreach ( $permissions as $permission ) : ?>
@ -35,12 +44,17 @@ if ( ! defined( 'ABSPATH' ) ) {
<div class="wc-auth-logged-in-as">
<?php echo get_avatar( $user->ID, 70 ); ?>
<p><?php printf( __( 'Logged in as %s', 'woocommerce' ), esc_html( $user->display_name ) ); ?> <a href="<?php echo esc_url( $logout_url ); ?>" class="wc-auth-logout"><?php _e( 'Logout', 'woocommerce' ); ?></a>
<p>
<?php
/* Translators: %s display name. */
printf( esc_html__( 'Logged in as %s', 'woocommerce' ), esc_html( $user->display_name ) );
?>
<a href="<?php echo esc_url( $logout_url ); ?>" class="wc-auth-logout"><?php esc_html_e( 'Logout', 'woocommerce' ); ?></a>
</div>
<p class="wc-auth-actions">
<a href="<?php echo esc_url( $granted_url ); ?>" class="button button-primary wc-auth-approve"><?php _e( 'Approve', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( $return_url ); ?>" class="button wc-auth-deny"><?php _e( 'Deny', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( $granted_url ); ?>" class="button button-primary wc-auth-approve"><?php esc_html_e( 'Approve', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( $return_url ); ?>" class="button wc-auth-deny"><?php esc_html_e( 'Deny', 'woocommerce' ); ?></a>
</p>
<?php do_action( 'woocommerce_auth_page_footer' ); ?>

View File

@ -10,25 +10,24 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates/Auth
* @version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<title><?php _e( 'Application authentication request', 'woocommerce' ); ?></title>
<title><?php esc_html_e( 'Application authentication request', 'woocommerce' ); ?></title>
<?php wp_admin_css( 'install', true ); ?>
<link rel="stylesheet" href="<?php echo esc_url( str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/css/auth.css' ); ?>" type="text/css" />
</head>
<body class="wc-auth wp-core-ui">
<h1 id="wc-logo"><img src="<?php echo WC()->plugin_url(); ?>/assets/images/woocommerce_logo.png" alt="WooCommerce" /></h1>
<h1 id="wc-logo"><img src="<?php echo esc_url( WC()->plugin_url() ); ?>/assets/images/woocommerce_logo.png" alt="<?php esc_attr_e( 'WooCommerce', 'woocommerce' ); ?>" /></h1>
<div class="wc-auth-content">

View File

@ -49,7 +49,7 @@ $calculator_text = '';
if ( $formatted_destination ) {
// Translators: $s shipping destination.
printf( esc_html__( 'Shipping to %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' );
$calculator_text = __( 'Change address', 'woocommerce' );
$calculator_text = esc_html__( 'Change address', 'woocommerce' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_estimate_html', __( 'Shipping options will be updated during checkout.', 'woocommerce' ) ) );
}
@ -64,7 +64,7 @@ $calculator_text = '';
else :
// Translators: $s shipping destination.
echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) );
$calculator_text = __( 'Enter a different address', 'woocommerce' );
$calculator_text = esc_html__( 'Enter a different address', 'woocommerce' );
endif;
?>

View File

@ -10,26 +10,24 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.3.6
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.3.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
?>
<div class="cart_totals <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>">
<?php do_action( 'woocommerce_before_cart_totals' ); ?>
<h2><?php _e( 'Cart totals', 'woocommerce' ); ?></h2>
<h2><?php esc_html_e( 'Cart totals', 'woocommerce' ); ?></h2>
<table cellspacing="0" class="shop_table shop_table_responsive">
<tr class="cart-subtotal">
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
@ -51,7 +49,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) : ?>
<tr class="shipping">
<th><?php _e( 'Shipping', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Shipping', 'woocommerce' ); ?></th>
<td data-title="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>"><?php woocommerce_shipping_calculator(); ?></td>
</tr>
@ -64,31 +62,40 @@ if ( ! defined( 'ABSPATH' ) ) {
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) :
<?php
if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) {
$taxable_address = WC()->customer->get_taxable_address();
$estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping()
? sprintf( ' <small>' . __( '(estimated for %s)', 'woocommerce' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] )
: '';
$estimated_text = '';
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
<th><?php echo esc_html( $tax->label ) . $estimated_text; ?></th>
if ( WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ) {
/* translators: %s location. */
$estimated_text = sprintf( ' <small>' . esc_html__( '(estimated for %s)', 'woocommerce' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] );
}
if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) {
foreach ( WC()->cart->get_tax_totals() as $code => $tax ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
<td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<?php
}
} else {
?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; ?></th>
<th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th>
<td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php
}
}
?>
<?php do_action( 'woocommerce_cart_totals_before_order_total' ); ?>
<tr class="order-total">
<th><?php _e( 'Total', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
</tr>

View File

@ -48,11 +48,10 @@ do_action( 'woocommerce_before_cart' ); ?>
<td class="product-remove">
<?php
// @codingStandardsIgnoreLine
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
__( 'Remove this item', 'woocommerce' ),
esc_html__( 'Remove this item', 'woocommerce' ),
esc_attr( $product_id ),
esc_attr( $_product->get_sku() )
), $cart_item_key );

View File

@ -10,38 +10,37 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.0.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
if ( $cross_sells ) : ?>
<div class="cross-sells">
<h2><?php _e( 'You may be interested in&hellip;', 'woocommerce' ); ?></h2>
<h2><?php esc_html_e( 'You may be interested in&hellip;', 'woocommerce' ); ?></h2>
<?php woocommerce_product_loop_start(); ?>
<?php foreach ( $cross_sells as $cross_sell ) : ?>
<?php
$post_object = get_post( $cross_sell->get_id() );
$post_object = get_post( $cross_sell->get_id() );
setup_postdata( $GLOBALS['post'] =& $post_object );
setup_postdata( $GLOBALS['post'] =& $post_object ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited, Squiz.PHP.DisallowMultipleAssignments.Found
wc_get_template_part( 'content', 'product' ); ?>
wc_get_template_part( 'content', 'product' );
?>
<?php endforeach; ?>
<?php woocommerce_product_loop_end(); ?>
</div>
<?php endif;
<?php
endif;
wp_reset_postdata();

View File

@ -16,9 +16,8 @@
* @package WooCommerce/Templates
* @version 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
do_action( 'woocommerce_before_mini_cart' ); ?>
@ -26,48 +25,52 @@ do_action( 'woocommerce_before_mini_cart' ); ?>
<ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">
<?php
do_action( 'woocommerce_before_mini_cart_contents' );
do_action( 'woocommerce_before_mini_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
$product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
?>
<li class="woocommerce-mini-cart-item <?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf(
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
$product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key );
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
$product_price = apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key );
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key );
?>
<li class="woocommerce-mini-cart-item <?php echo esc_attr( apply_filters( 'woocommerce_mini_cart_item_class', 'mini_cart_item', $cart_item, $cart_item_key ) ); ?>">
<?php
echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'woocommerce_cart_item_remove_link',
sprintf(
'<a href="%s" class="remove remove_from_cart_button" aria-label="%s" data-product_id="%s" data-cart_item_key="%s" data-product_sku="%s">&times;</a>',
esc_url( wc_get_cart_remove_url( $cart_item_key ) ),
__( 'Remove this item', 'woocommerce' ),
esc_html__( 'Remove this item', 'woocommerce' ),
esc_attr( $product_id ),
esc_attr( $cart_item_key ),
esc_attr( $_product->get_sku() )
), $cart_item_key );
?>
<?php if ( empty( $product_permalink ) ) : ?>
<?php echo $thumbnail . $product_name; ?>
<?php else : ?>
<a href="<?php echo esc_url( $product_permalink ); ?>">
<?php echo $thumbnail . $product_name; ?>
</a>
<?php endif; ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); ?>
<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); ?>
</li>
<?php
}
),
$cart_item_key
);
?>
<?php if ( empty( $product_permalink ) ) : ?>
<?php echo $thumbnail . $product_name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<a href="<?php echo esc_url( $product_permalink ); ?>">
<?php echo $thumbnail . $product_name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a>
<?php endif; ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . sprintf( '%s &times; %s', $cart_item['quantity'], $product_price ) . '</span>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</li>
<?php
}
}
do_action( 'woocommerce_mini_cart_contents' );
do_action( 'woocommerce_mini_cart_contents' );
?>
</ul>
<p class="woocommerce-mini-cart__total total"><strong><?php _e( 'Subtotal', 'woocommerce' ); ?>:</strong> <?php echo WC()->cart->get_cart_subtotal(); ?></p>
<p class="woocommerce-mini-cart__total total"><strong><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?>:</strong> <?php echo WC()->cart->get_cart_subtotal(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?>
@ -75,7 +78,7 @@ do_action( 'woocommerce_before_mini_cart' ); ?>
<?php else : ?>
<p class="woocommerce-mini-cart__empty-message"><?php _e( 'No products in the cart.', 'woocommerce' ); ?></p>
<p class="woocommerce-mini-cart__empty-message"><?php esc_html_e( 'No products in the cart.', 'woocommerce' ); ?></p>
<?php endif; ?>

View File

@ -23,7 +23,7 @@ if ( ! wc_coupons_enabled() ) { // @codingStandardsIgnoreLine.
?>
<div class="woocommerce-form-coupon-toggle">
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', __( 'Have a coupon?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . __( 'Click here to enter your code', 'woocommerce' ) . '</a>' ), 'notice' ); ?>
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_coupon_message', esc_html__( 'Have a coupon?', 'woocommerce' ) . ' <a href="#" class="showcoupon">' . esc_html__( 'Click here to enter your code', 'woocommerce' ) . '</a>' ), 'notice' ); ?>
</div>
<form class="checkout_coupon woocommerce-form-coupon" method="post" style="display:none">

View File

@ -23,13 +23,13 @@ if ( is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_lo
?>
<div class="woocommerce-form-login-toggle">
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', __( 'Returning customer?', 'woocommerce' ) ) . ' <a href="#" class="showlogin">' . __( 'Click here to login', 'woocommerce' ) . '</a>', 'notice' ); ?>
<?php wc_print_notice( apply_filters( 'woocommerce_checkout_login_message', esc_html__( 'Returning customer?', 'woocommerce' ) ) . ' <a href="#" class="showlogin">' . esc_html__( 'Click here to login', 'woocommerce' ) . '</a>', 'notice' ); ?>
</div>
<?php
woocommerce_login_form(
array(
'message' => __( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing section.', 'woocommerce' ),
'message' => esc_html__( 'If you have shopped with us before, please enter your details below. If you are a new customer, please proceed to the Billing section.', 'woocommerce' ),
'redirect' => wc_get_page_permalink( 'checkout' ),
'hidden' => true,
)

View File

@ -17,7 +17,7 @@
defined( 'ABSPATH' ) || exit;
$totals = $order->get_order_item_totals();
$totals = $order->get_order_item_totals(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
?>
<form id="order_review" method="post">
@ -76,7 +76,7 @@ $totals = $order->get_order_item_totals();
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
}
} else {
echo '<li class="woocommerce-notice woocommerce-notice--info woocommerce-info">' . apply_filters( 'woocommerce_no_available_payment_methods_message', __( 'Sorry, it seems that there are no available payment methods for your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) ) . '</li>'; // @codingStandardsIgnoreLine
echo '<li class="woocommerce-notice woocommerce-notice--info woocommerce-info">' . apply_filters( 'woocommerce_no_available_payment_methods_message', esc_html__( 'Sorry, it seems that there are no available payment methods for your location. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) ) . '</li>'; // @codingStandardsIgnoreLine
}
?>
</ul>

View File

@ -10,52 +10,50 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.3.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<thead>
<tr>
<th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
<th class="product-total"><?php _e( 'Total', 'woocommerce' ); ?></th>
<th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
<th class="product-total"><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
</tr>
</thead>
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;'; ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '&times; %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); ?>
</td>
<td class="product-total">
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?>
</td>
</tr>
<?php
}
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . '&nbsp;'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '&times; %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
<td class="product-total">
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
<tfoot>
<tr class="cart-subtotal">
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
@ -85,8 +83,8 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
@ -102,7 +100,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php _e( 'Total', 'woocommerce' ); ?></th>
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>

View File

@ -10,14 +10,12 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.2.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
?>
<div class="woocommerce-order">
@ -28,46 +26,46 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?></p>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed"><?php esc_html_e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction. Please attempt your purchase again.', 'woocommerce' ); ?></p>
<p class="woocommerce-notice woocommerce-notice--error woocommerce-thankyou-order-failed-actions">
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php _e( 'Pay', 'woocommerce' ) ?></a>
<a href="<?php echo esc_url( $order->get_checkout_payment_url() ); ?>" class="button pay"><?php esc_html_e( 'Pay', 'woocommerce' ); ?></a>
<?php if ( is_user_logged_in() ) : ?>
<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php _e( 'My account', 'woocommerce' ); ?></a>
<a href="<?php echo esc_url( wc_get_page_permalink( 'myaccount' ) ); ?>" class="button pay"><?php esc_html_e( 'My account', 'woocommerce' ); ?></a>
<?php endif; ?>
</p>
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<ul class="woocommerce-order-overview woocommerce-thankyou-order-details order_details">
<li class="woocommerce-order-overview__order order">
<?php _e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); ?></strong>
<?php esc_html_e( 'Order number:', 'woocommerce' ); ?>
<strong><?php echo $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<li class="woocommerce-order-overview__date date">
<?php _e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); ?></strong>
<?php esc_html_e( 'Date:', 'woocommerce' ); ?>
<strong><?php echo wc_format_datetime( $order->get_date_created() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<?php if ( is_user_logged_in() && $order->get_user_id() === get_current_user_id() && $order->get_billing_email() ) : ?>
<li class="woocommerce-order-overview__email email">
<?php _e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $order->get_billing_email(); ?></strong>
<?php esc_html_e( 'Email:', 'woocommerce' ); ?>
<strong><?php echo $order->get_billing_email(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<?php endif; ?>
<li class="woocommerce-order-overview__total total">
<?php _e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); ?></strong>
<?php esc_html_e( 'Total:', 'woocommerce' ); ?>
<strong><?php echo $order->get_formatted_order_total(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></strong>
</li>
<?php if ( $order->get_payment_method_title() ) : ?>
<li class="woocommerce-order-overview__payment-method method">
<?php _e( 'Payment method:', 'woocommerce' ); ?>
<?php esc_html_e( 'Payment method:', 'woocommerce' ); ?>
<strong><?php echo wp_kses_post( $order->get_payment_method_title() ); ?></strong>
</li>
<?php endif; ?>
@ -81,7 +79,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php else : ?>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
<p class="woocommerce-notice woocommerce-notice--success woocommerce-thankyou-order-received"><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', esc_html__( 'Thank you. Your order has been received.', 'woocommerce' ), null ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php endif; ?>

View File

@ -15,9 +15,7 @@
* @version 3.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/*
* @hooked WC_Emails::email_header() Output the email header
@ -25,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s: Customer billing full name */ ?>
<p><?php printf( __( 'Youve received the following order from %s:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<p><?php printf( esc_html__( 'Youve received the following order from %s:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php
/*

View File

@ -15,19 +15,14 @@
* @version 3.5.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
defined( 'ABSPATH' ) || exit;
?>
<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s Customer username */ ?>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $user_login ) ); ?></p>
<?php /* translators: %1$s: Site title, %2$s: Username, %3$s: My account link */ ?>
<p><?php printf( __( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<p><?php printf( esc_html__( 'Thanks for creating an account on %1$s. Your username is %2$s. You can access your account area to view orders, change your password, and more at: %3$s', 'woocommerce' ), esc_html( $blogname ), '<strong>' . esc_html( $user_login ) . '</strong>', make_clickable( esc_url( wc_get_page_permalink( 'myaccount' ) ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<?php if ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) && $password_generated ) : ?>
<?php /* translators: %s Auto generated password */ ?>
<p><?php printf( esc_html__( 'Your password has been automatically generated: %s', 'woocommerce' ), '<strong>' . esc_html( $user_pass ) . '</strong>' ); ?></p>

View File

@ -15,9 +15,7 @@
* @version 3.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/*
* @hooked WC_Emails::email_header() Output the email header
@ -25,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) {
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s: Customer first name */ ?>
<p><?php printf( __( 'Hi %s,', 'woocommerce' ), $order->get_billing_first_name() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
<p><?php esc_html_e( 'Thanks for your order. Its on-hold until we confirm that payment has been received. In the meantime, heres a reminder of what you ordered:', 'woocommerce' ); ?></p>
<?php

View File

@ -15,9 +15,7 @@
* @version 3.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
/*
* @hooked WC_Emails::email_header() Output the email header
@ -25,16 +23,16 @@ if ( ! defined( 'ABSPATH' ) ) {
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php /* translators: %s: Customer first name */ ?>
<p><?php printf( __( 'Hi %s,', 'woocommerce' ), $order->get_billing_first_name() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<p><?php printf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ); ?></p>
<p>
<?php
if ( $partial_refund ) {
/* translators: %s: Site title */
printf( __( 'Your order on %s has been partially refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
printf( esc_html__( 'Your order on %s has been partially refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
} else {
/* translators: %s: Site title */
printf( __( 'Your order on %s has been refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
printf( esc_html__( 'Your order on %s has been refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
}
?>
</p>

View File

@ -17,14 +17,11 @@
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
?>
<?php if ( ! empty( $fields ) ) : ?>
<div style="font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; margin-bottom: 40px;">
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<h2><?php esc_html_e( 'Customer details', 'woocommerce' ); ?></h2>
<ul>
<?php foreach ( $fields as $field ) : ?>
<li><strong><?php echo wp_kses_post( $field['label'] ); ?>:</strong> <span class="text"><?php echo wp_kses_post( $field['value'] ); ?></span></li>

View File

@ -22,8 +22,8 @@ echo esc_html( wp_strip_all_tags( $email_heading ) );
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
echo sprintf( __( 'Hi %s,', 'woocommerce' ), $order->get_billing_first_name() ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo __( 'Thanks for your order. Its on-hold until we confirm that payment has been received. In the meantime, heres a reminder of what you ordered:', 'woocommerce' ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), esc_html( $order->get_billing_first_name() ) ) . "\n\n";
echo esc_html__( 'Thanks for your order. Its on-hold until we confirm that payment has been received. In the meantime, heres a reminder of what you ordered:', 'woocommerce' ) . "\n\n";
/*
* @hooked WC_Emails::order_details() Shows the order details table.

View File

@ -22,13 +22,13 @@ echo esc_html( wp_strip_all_tags( $email_heading ) );
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/* translators: %s: Customer first name */
echo sprintf( __( 'Hi %s,', 'woocommerce' ), $order->get_billing_first_name() ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), $order->get_billing_first_name() ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
if ( $partial_refund ) {
/* translators: %s: Site title */
echo sprintf( __( 'Your order on %s has been partially refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo sprintf( esc_html__( 'Your order on %s has been partially refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
} else {
/* translators: %s: Site title */
echo sprintf( __( 'Your order on %s has been refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo sprintf( esc_html__( 'Your order on %s has been refunded. There are more details below for your reference:', 'woocommerce' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
}
/*

View File

@ -15,11 +15,9 @@
* @version 3.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
echo "\n" . esc_html( wc_strtoupper( __( 'Billing address', 'woocommerce' ) ) ) . "\n\n";
echo "\n" . esc_html( wc_strtoupper( esc_html__( 'Billing address', 'woocommerce' ) ) ) . "\n\n";
echo preg_replace( '#<br\s*/?>#i', "\n", $order->get_formatted_billing_address() ) . "\n"; // WPCS: XSS ok.
if ( $order->get_billing_phone() ) {
@ -34,7 +32,7 @@ if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() ) {
$shipping = $order->get_formatted_shipping_address();
if ( $shipping ) {
echo "\n" . esc_html( wc_strtoupper( __( 'Shipping address', 'woocommerce' ) ) ) . "\n\n";
echo "\n" . esc_html( wc_strtoupper( esc_html__( 'Shipping address', 'woocommerce' ) ) ) . "\n\n";
echo preg_replace( '#<br\s*/?>#i', "\n", $shipping ) . "\n"; // WPCS: XSS ok.
}
}

View File

@ -17,11 +17,9 @@
* @version 3.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
echo esc_html( wc_strtoupper( __( 'Customer details', 'woocommerce' ) ) ) . "\n\n";
echo esc_html( wc_strtoupper( esc_html__( 'Customer details', 'woocommerce' ) ) ) . "\n\n";
foreach ( $fields as $field ) {
echo wp_kses_post( $field['label'] ) . ': ' . wp_kses_post( $field['value'] ) . "\n";

View File

@ -17,7 +17,7 @@
defined( 'ABSPATH' ) || exit;
echo esc_html( wc_strtoupper( __( 'Downloads', 'woocommerce' ) ) ) . "\n\n";
echo esc_html( wc_strtoupper( esc_html__( 'Downloads', 'woocommerce' ) ) ) . "\n\n";
foreach ( $downloads as $download ) {
foreach ( $columns as $column_id => $column_name ) {

View File

@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit;
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email );
/* translators: %1$s: Order ID. %2$s: Order date */
echo wp_kses_post( wc_strtoupper( sprintf( __( '[Order #%1$s] (%2$s)', 'woocommerce' ), $order->get_order_number(), wc_format_datetime( $order->get_date_created() ) ) ) ) . "\n";
echo wp_kses_post( wc_strtoupper( sprintf( esc_html__( '[Order #%1$s] (%2$s)', 'woocommerce' ), $order->get_order_number(), wc_format_datetime( $order->get_date_created() ) ) ) ) . "\n";
echo "\n" . wc_get_email_order_items( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$order,
array(

View File

@ -25,7 +25,7 @@ if ( $max_value && $min_value === $max_value ) {
<?php
} else {
/* translators: %s: Quantity. */
$label = ! empty( $args['product_name'] ) ? sprintf( __( '%s quantity', 'woocommerce' ), wp_strip_all_tags( $args['product_name'] ) ) : __( 'Quantity', 'woocommerce' );
$label = ! empty( $args['product_name'] ) ? sprintf( esc_html__( '%s quantity', 'woocommerce' ), wp_strip_all_tags( $args['product_name'] ) ) : esc_html__( 'Quantity', 'woocommerce' );
?>
<div class="quantity">
<?php do_action( 'woocommerce_before_quantity_input_field' ); ?>

View File

@ -10,14 +10,12 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.0.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
?>
<p class="woocommerce-info"><?php _e( 'No products were found matching your selection.', 'woocommerce' ); ?></p>
<p class="woocommerce-info"><?php esc_html_e( 'No products were found matching your selection.', 'woocommerce' ); ?></p>

View File

@ -17,7 +17,7 @@
defined( 'ABSPATH' ) || exit;
$page_title = ( 'billing' === $load_address ) ? __( 'Billing address', 'woocommerce' ) : __( 'Shipping address', 'woocommerce' );
$page_title = ( 'billing' === $load_address ) ? esc_html__( 'Billing address', 'woocommerce' ) : esc_html__( 'Shipping address', 'woocommerce' );
do_action( 'woocommerce_before_edit_account_address_form' ); ?>

View File

@ -15,11 +15,9 @@
* @version 3.5.2
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
wc_print_notice( __( 'Password reset email has been sent.', 'woocommerce' ) );
wc_print_notice( esc_html__( 'Password reset email has been sent.', 'woocommerce' ) );
?>
<p><?php echo esc_html( apply_filters( 'woocommerce_lost_password_confirmation_message', __( 'A password reset email has been sent to the email address on file for your account, but may take several minutes to show up in your inbox. Please wait at least 10 minutes before attempting another reset.', 'woocommerce' ) ) ); ?></p>
<p><?php echo esc_html( apply_filters( 'woocommerce_lost_password_confirmation_message', esc_html__( 'A password reset email has been sent to the email address on file for your account, but may take several minutes to show up in your inbox. Please wait at least 10 minutes before attempting another reset.', 'woocommerce' ) ) ); ?></p>

View File

@ -15,21 +15,27 @@
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
$customer_id = get_current_user_id();
if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) {
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing address', 'woocommerce' ),
'shipping' => __( 'Shipping address', 'woocommerce' ),
), $customer_id );
$get_addresses = apply_filters(
'woocommerce_my_account_get_addresses',
array(
'billing' => __( 'Billing address', 'woocommerce' ),
'shipping' => __( 'Shipping address', 'woocommerce' ),
),
$customer_id
);
} else {
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array(
'billing' => __( 'Billing address', 'woocommerce' ),
), $customer_id );
$get_addresses = apply_filters(
'woocommerce_my_account_get_addresses',
array(
'billing' => __( 'Billing address', 'woocommerce' ),
),
$customer_id
);
}
$oldcol = 1;
@ -37,29 +43,35 @@ $col = 1;
?>
<p>
<?php echo apply_filters( 'woocommerce_my_account_my_address_description', __( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ) ); ?>
<?php echo apply_filters( 'woocommerce_my_account_my_address_description', esc_html__( 'The following addresses will be used on the checkout page by default.', 'woocommerce' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</p>
<?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?>
<div class="u-columns woocommerce-Addresses col2-set addresses">
<?php endif; ?>
<?php foreach ( $get_addresses as $name => $title ) :
$address = wc_get_account_formatted_address( $name ); ?>
<?php foreach ( $get_addresses as $name => $address_title ) : ?>
<?php
$address = wc_get_account_formatted_address( $name );
$col = $col * -1;
$oldcol = $oldcol * -1;
?>
<div class="u-column<?php echo ( ( $col = $col * -1 ) < 0 ) ? 1 : 2; ?> col-<?php echo ( ( $oldcol = $oldcol * -1 ) < 0 ) ? 1 : 2; ?> woocommerce-Address">
<div class="u-column<?php echo $col < 0 ? 1 : 2; ?> col-<?php echo $oldcol < 0 ? 1 : 2; ?> woocommerce-Address">
<header class="woocommerce-Address-title title">
<h3><?php echo $title; ?></h3>
<h3><?php echo esc_html( $address_title ); ?></h3>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php echo $address ? esc_html__( 'Edit', 'woocommerce' ) : esc_html__( 'Add', 'woocommerce' ); ?></a>
</header>
<address><?php
echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'woocommerce' );
?></address>
<address>
<?php
echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'woocommerce' );
?>
</address>
</div>
<?php endforeach; ?>
<?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?>
</div>
<?php endif;
<?php
endif;

View File

@ -18,29 +18,30 @@
* @deprecated 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
if ( $downloads = WC()->customer->get_downloadable_products() ) : ?>
$downloads = WC()->customer->get_downloadable_products();
if ( $downloads ) : ?>
<?php do_action( 'woocommerce_before_available_downloads' ); ?>
<h2><?php echo apply_filters( 'woocommerce_my_account_my_downloads_title', __( 'Available downloads', 'woocommerce' ) ); ?></h2>
<h2><?php echo apply_filters( 'woocommerce_my_account_my_downloads_title', esc_html__( 'Available downloads', 'woocommerce' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h2>
<ul class="woocommerce-Downloads digital-downloads">
<?php foreach ( $downloads as $download ) : ?>
<li>
<?php
do_action( 'woocommerce_available_download_start', $download );
do_action( 'woocommerce_available_download_start', $download );
if ( is_numeric( $download['downloads_remaining'] ) ) {
echo apply_filters( 'woocommerce_available_download_count', '<span class="woocommerce-Count count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'woocommerce' ), $download['downloads_remaining'] ) . '</span> ', $download );
}
if ( is_numeric( $download['downloads_remaining'] ) ) {
/* translators: %s product name */
echo apply_filters( 'woocommerce_available_download_count', '<span class="woocommerce-Count count">' . sprintf( _n( '%s download remaining', '%s downloads remaining', $download['downloads_remaining'], 'woocommerce' ), $download['downloads_remaining'] ) . '</span> ', $download ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo apply_filters( 'woocommerce_available_download_link', '<a href="' . esc_url( $download['download_url'] ) . '">' . $download['download_name'] . '</a>', $download );
echo apply_filters( 'woocommerce_available_download_link', '<a href="' . esc_url( $download['download_url'] ) . '">' . $download['download_name'] . '</a>', $download ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
do_action( 'woocommerce_available_download_end', $download );
do_action( 'woocommerce_available_download_end', $download );
?>
</li>
<?php endforeach; ?>

View File

@ -3,31 +3,38 @@
* My Orders - Deprecated
*
* @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
* @package WooCommerce/Templates
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
$my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array(
'order-number' => __( 'Order', 'woocommerce' ),
'order-date' => __( 'Date', 'woocommerce' ),
'order-status' => __( 'Status', 'woocommerce' ),
'order-total' => __( 'Total', 'woocommerce' ),
'order-actions' => '&nbsp;',
) );
$my_orders_columns = apply_filters(
'woocommerce_my_account_my_orders_columns',
array(
'order-number' => esc_html__( 'Order', 'woocommerce' ),
'order-date' => esc_html__( 'Date', 'woocommerce' ),
'order-status' => esc_html__( 'Status', 'woocommerce' ),
'order-total' => esc_html__( 'Total', 'woocommerce' ),
'order-actions' => '&nbsp;',
)
);
$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array(
'numberposts' => $order_count,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ),
) ) );
$customer_orders = get_posts(
apply_filters(
'woocommerce_my_account_my_orders_query',
array(
'numberposts' => $order_count,
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ),
)
)
);
if ( $customer_orders ) : ?>
<h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent orders', 'woocommerce' ) ); ?></h2>
<h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', esc_html__( 'Recent orders', 'woocommerce' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h2>
<table class="shop_table shop_table_responsive my_account_orders">
@ -40,8 +47,9 @@ if ( $customer_orders ) : ?>
</thead>
<tbody>
<?php foreach ( $customer_orders as $customer_order ) :
$order = wc_get_order( $customer_order );
<?php
foreach ( $customer_orders as $customer_order ) :
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
$item_count = $order->get_item_count();
?>
<tr class="order">
@ -52,7 +60,7 @@ if ( $customer_orders ) : ?>
<?php elseif ( 'order-number' === $column_id ) : ?>
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
<?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); ?>
<?php echo _x( '#', 'hash before order number', 'woocommerce' ) . $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a>
<?php elseif ( 'order-date' === $column_id ) : ?>
@ -64,15 +72,15 @@ if ( $customer_orders ) : ?>
<?php elseif ( 'order-total' === $column_id ) : ?>
<?php
/* translators: 1: formatted order total 2: total order items */
printf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count );
printf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
<?php elseif ( 'order-actions' === $column_id ) : ?>
<?php
$actions = wc_get_account_orders_actions( $order );
if ( ! empty( $actions ) ) {
foreach ( $actions as $key => $action ) {
foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>';
}
}

View File

@ -17,9 +17,7 @@
* @version 3.7.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
do_action( 'woocommerce_before_account_orders', $has_orders ); ?>

View File

@ -12,14 +12,12 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
$saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() );
$has_methods = (bool) $saved_methods;
@ -37,7 +35,7 @@ do_action( 'woocommerce_before_account_payment_methods', $has_methods ); ?>
<?php endforeach; ?>
</tr>
</thead>
<?php foreach ( $saved_methods as $type => $methods ) : ?>
<?php foreach ( $saved_methods as $type => $methods ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited ?>
<?php foreach ( $methods as $method ) : ?>
<tr class="payment-method<?php echo ! empty( $method['is_default'] ) ? ' default-payment-method' : ''; ?>">
<?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
@ -48,14 +46,14 @@ do_action( 'woocommerce_before_account_payment_methods', $has_methods ); ?>
} elseif ( 'method' === $column_id ) {
if ( ! empty( $method['method']['last4'] ) ) {
/* translators: 1: credit card type 2: last 4 digits */
echo sprintf( __( '%1$s ending in %2$s', 'woocommerce' ), esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) ), esc_html( $method['method']['last4'] ) );
echo sprintf( esc_html__( '%1$s ending in %2$s', 'woocommerce' ), esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) ), esc_html( $method['method']['last4'] ) );
} else {
echo esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) );
}
} elseif ( 'expires' === $column_id ) {
echo esc_html( $method['expires'] );
} elseif ( 'actions' === $column_id ) {
foreach ( $method['actions'] as $key => $action ) {
foreach ( $method['actions'] as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>&nbsp;';
}
}

View File

@ -17,34 +17,35 @@
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
$notes = $order->get_customer_order_notes();
?>
<p><?php
<p>
<?php
printf(
/* translators: 1: order number 2: order date 3: order status */
printf(
__( 'Order #%1$s was placed on %2$s and is currently %3$s.', 'woocommerce' ),
'<mark class="order-number">' . $order->get_order_number() . '</mark>',
'<mark class="order-date">' . wc_format_datetime( $order->get_date_created() ) . '</mark>',
'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>'
);
?></p>
esc_html__( 'Order #%1$s was placed on %2$s and is currently %3$s.', 'woocommerce' ),
'<mark class="order-number">' . $order->get_order_number() . '</mark>', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'<mark class="order-date">' . wc_format_datetime( $order->get_date_created() ) . '</mark>', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
);
?>
</p>
<?php if ( $notes = $order->get_customer_order_notes() ) : ?>
<h2><?php _e( 'Order updates', 'woocommerce' ); ?></h2>
<?php if ( $notes ) : ?>
<h2><?php esc_html_e( 'Order updates', 'woocommerce' ); ?></h2>
<ol class="woocommerce-OrderUpdates commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="woocommerce-OrderUpdate comment note">
<div class="woocommerce-OrderUpdate-inner comment_container">
<div class="woocommerce-OrderUpdate-text comment-text">
<p class="woocommerce-OrderUpdate-meta meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
<p class="woocommerce-OrderUpdate-meta meta"><?php echo date_i18n( esc_html__( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<div class="woocommerce-OrderUpdate-description description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
<?php echo wpautop( wptexturize( $note->comment_content ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>

View File

@ -15,9 +15,8 @@
* @version 3.4.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
defined( 'ABSPATH' ) || exit;
$show_shipping = ! wc_ship_to_billing_address_only() && $order->needs_shipping_address();
?>
<section class="woocommerce-customer-details">
@ -32,7 +31,7 @@ $show_shipping = ! wc_ship_to_billing_address_only() && $order->needs_shipping_a
<h2 class="woocommerce-column__title"><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
<address>
<?php echo wp_kses_post( $order->get_formatted_billing_address( __( 'N/A', 'woocommerce' ) ) ); ?>
<?php echo wp_kses_post( $order->get_formatted_billing_address( esc_html__( 'N/A', 'woocommerce' ) ) ); ?>
<?php if ( $order->get_billing_phone() ) : ?>
<p class="woocommerce-customer-details--phone"><?php echo esc_html( $order->get_billing_phone() ); ?></p>
@ -50,7 +49,7 @@ $show_shipping = ! wc_ship_to_billing_address_only() && $order->needs_shipping_a
<div class="woocommerce-column woocommerce-column--2 woocommerce-column--shipping-address col-2">
<h2 class="woocommerce-column__title"><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>
<address>
<?php echo wp_kses_post( $order->get_formatted_shipping_address( __( 'N/A', 'woocommerce' ) ) ); ?>
<?php echo wp_kses_post( $order->get_formatted_shipping_address( esc_html__( 'N/A', 'woocommerce' ) ) ); ?>
</address>
</div><!-- /.col-2 -->

View File

@ -10,36 +10,43 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.2.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
$notes = $order->get_customer_order_notes();
?>
<p class="order-info"><?php
/* translators: 1: order number 2: order date 3: order status */
echo wp_kses_post( apply_filters( 'woocommerce_order_tracking_status', sprintf(
__( 'Order #%1$s was placed on %2$s and is currently %3$s.', 'woocommerce' ),
'<mark class="order-number">' . $order->get_order_number() . '</mark>',
'<mark class="order-date">' . wc_format_datetime( $order->get_date_created() ) . '</mark>',
'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>'
) ) );
?></p>
<p class="order-info">
<?php
echo wp_kses_post(
apply_filters(
'woocommerce_order_tracking_status',
sprintf(
/* translators: 1: order number 2: order date 3: order status */
__( 'Order #%1$s was placed on %2$s and is currently %3$s.', 'woocommerce' ),
'<mark class="order-number">' . $order->get_order_number() . '</mark>',
'<mark class="order-date">' . wc_format_datetime( $order->get_date_created() ) . '</mark>',
'<mark class="order-status">' . wc_get_order_status_name( $order->get_status() ) . '</mark>'
)
)
);
?>
</p>
<?php if ( $notes = $order->get_customer_order_notes() ) : ?>
<h2><?php _e( 'Order updates', 'woocommerce' ); ?></h2>
<?php if ( $notes ) : ?>
<h2><?php esc_html_e( 'Order updates', 'woocommerce' ); ?></h2>
<ol class="commentlist notes">
<?php foreach ( $notes as $note ) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo date_i18n( __( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); ?></p>
<p class="meta"><?php echo date_i18n( esc_html__( 'l jS \o\f F Y, h:ia', 'woocommerce' ), strtotime( $note->comment_date ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
<div class="description">
<?php echo wpautop( wptexturize( $note->comment_content ) ); ?>
<?php echo wpautop( wptexturize( $note->comment_content ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<div class="clear"></div>
</div>

View File

@ -15,9 +15,7 @@
* @version 3.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
defined( 'ABSPATH' ) || exit;
global $product;
@ -71,27 +69,51 @@ if ( ! comments_open() ) {
<div id="review_form_wrapper">
<div id="review_form">
<?php
$commenter = wp_get_current_commenter();
$commenter = wp_get_current_commenter();
$comment_form = array(
/* translators: %s is product title */
'title_reply' => have_comments() ? __( 'Add a review', 'woocommerce' ) : sprintf( __( 'Be the first to review &ldquo;%s&rdquo;', 'woocommerce' ), get_the_title() ),
'title_reply' => have_comments() ? esc_html__( 'Add a review', 'woocommerce' ) : sprintf( esc_html__( 'Be the first to review &ldquo;%s&rdquo;', 'woocommerce' ), get_the_title() ),
/* translators: %s is product title */
'title_reply_to' => __( 'Leave a Reply to %s', 'woocommerce' ),
'title_reply_to' => esc_html__( 'Leave a Reply to %s', 'woocommerce' ),
'title_reply_before' => '<span id="reply-title" class="comment-reply-title">',
'title_reply_after' => '</span>',
'comment_notes_after' => '',
'fields' => array(
'author' => '<p class="comment-form-author"><label for="author">' . esc_html__( 'Name', 'woocommerce' ) . '&nbsp;<span class="required">*</span></label> ' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" required /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . esc_html__( 'Email', 'woocommerce' ) . '&nbsp;<span class="required">*</span></label> ' .
'<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" required /></p>',
),
'label_submit' => __( 'Submit', 'woocommerce' ),
'label_submit' => esc_html__( 'Submit', 'woocommerce' ),
'logged_in_as' => '',
'comment_field' => '',
);
$name_email_required = (bool) get_option( 'require_name_email', 1 );
$fields = array(
'author' => array(
'label' => __( 'Name', 'woocommerce' ),
'type' => 'text',
'value' => $commenter['comment_author'],
'required' => $name_email_required,
),
'email' => array(
'label' => __( 'Email', 'woocommerce' ),
'type' => 'email',
'value' => $commenter['comment_author_email'],
'required' => $name_email_required,
),
);
$comment_form['fields'] = array();
foreach ( $fields as $key => $field ) {
$field_html = '<p class="comment-form-' . esc_attr( $key ) . '">';
$field_html .= '<label for="' . esc_attr( $key ) . '">' . esc_html( $field['label'] );
if ( $field['required'] ) {
$field_html .= '&nbsp;<span class="required">*</span>';
}
$field_html .= '</label><input id="' . esc_attr( $key ) . '" name="' . esc_attr( $key ) . '" type="' . esc_attr( $field['type'] ) . '" value="' . esc_attr( $field['value'] ) . '" size="30" ' . ( $field['required'] ? 'required' : '' ) . ' /></p>';
$comment_form['fields'][ $key ] = $field_html;
}
$account_page_url = wc_get_page_permalink( 'myaccount' );
if ( $account_page_url ) {
/* translators: %s opening and closing link tags respectively */

View File

@ -5,7 +5,7 @@
* This is a javascript-based template for single variations (see https://codex.wordpress.org/Javascript_Reference/wp.template).
* The values will be dynamically replaced after selecting attributes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.5.0
*/
@ -19,5 +19,5 @@ defined( 'ABSPATH' ) || exit;
<div class="woocommerce-variation-availability">{{{ data.variation.availability_html }}}</div>
</script>
<script type="text/template" id="tmpl-unavailable-variation-template">
<p><?php _e( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ); ?></p>
<p><?php esc_html_e( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ); ?></p>
</script>

View File

@ -10,23 +10,21 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.0.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
global $product;
$heading = esc_html( apply_filters( 'woocommerce_product_additional_information_heading', __( 'Additional information', 'woocommerce' ) ) );
$heading = apply_filters( 'woocommerce_product_additional_information_heading', __( 'Additional information', 'woocommerce' ) );
?>
<?php if ( $heading ) : ?>
<h2><?php echo $heading; ?></h2>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php do_action( 'woocommerce_product_additional_information', $product ); ?>

View File

@ -10,23 +10,21 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.0.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
defined( 'ABSPATH' ) || exit;
global $post;
$heading = esc_html( apply_filters( 'woocommerce_product_description_heading', __( 'Description', 'woocommerce' ) ) );
$heading = apply_filters( 'woocommerce_product_description_heading', __( 'Description', 'woocommerce' ) );
?>
<?php if ( $heading ) : ?>
<h2><?php echo $heading; ?></h2>
<h2><?php echo esc_html( $heading ); ?></h2>
<?php endif; ?>
<?php the_content(); ?>

View File

@ -207,7 +207,7 @@ PHP
php wp-cli.phar search-replace "http://local.wordpress.test" "$WP_SITE_URL"
php wp-cli.phar theme install twentytwelve --activate
php wp-cli.phar plugin install https://github.com/$REPO/archive/$BRANCH.zip --activate
php wp-cli.phar wc update
cd "$WORKING_DIR"
fi

View File

@ -1,10 +1,18 @@
<?php
/**
* Cart tests.
*
* @package WooCommerce\Tests\Cart
*/
/**
* Class Cart.
* @package WooCommerce\Tests\Cart
*/
class WC_Tests_Cart extends WC_Unit_Test_Case {
/**
* tearDown.
*/
public function tearDown() {
parent::tearDown();
@ -85,7 +93,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
)
);
// Add product to cart x1, calc and test
// Add product to cart x1, calc and test.
WC()->cart->add_to_cart( $product->get_id(), 1 );
WC()->cart->calculate_totals();
$this->assertEquals( '85.92', number_format( WC()->cart->total, 2, '.', '' ) );
@ -101,8 +109,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
/**
* Test tax rounding.
* Ticket:
* https://github.com/woocommerce/woocommerce/issues/21021
* Ticket: https://github.com/woocommerce/woocommerce/issues/21021.
*/
public function test_cart_get_total_issue_21021() {
update_option( 'woocommerce_prices_include_tax', 'yes' );
@ -135,14 +142,14 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
);
$tax_rate_5 = WC_Tax::_insert_tax_rate( $tax_rate );
// Create product with price 19
// Create product with price 19.
$product = WC_Helper_Product::create_simple_product();
$product->set_price( 19 );
$product->set_regular_price( 19 );
$product->set_tax_class( '5percent' );
$product->save();
// Create product with price 59
// Create product with price 59.
$product2 = WC_Helper_Product::create_simple_product();
$product2->set_price( 59 );
$product2->set_regular_price( 59 );
@ -165,16 +172,16 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
WC()->cart->empty_cart();
// Set the flat_rate shipping method
// Set the flat_rate shipping method.
WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
// Add product to cart x1, calc and test
// Add product to cart x1, calc and test.
WC()->cart->add_to_cart( $product->get_id(), 1 );
WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
WC()->cart->calculate_totals();
$this->assertEquals( 28.9, WC()->cart->total );
// Add product2 to cart
// Add product2 to cart.
WC()->cart->add_to_cart( $product2->get_id(), 1 );
WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
WC()->cart->calculate_totals();
@ -236,34 +243,33 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
/**
* Test some discount logic which has caused issues in the past.
* Ticket:
* https://github.com/woocommerce/woocommerce/issues/10963
* Ticket: https://github.com/woocommerce/woocommerce/issues/10963.
*
* Due to discounts being split amongst products in cart.
*/
public function test_cart_get_discounted_price_issue_10963() {
// Create dummy coupon - fixed cart, 1 value
// Create dummy coupon - fixed cart, 1 value.
$coupon = WC_Helper_Coupon::create_coupon();
// Add coupon
// Add coupon.
WC()->cart->add_discount( $coupon->get_code() );
// Create dummy product - price will be 10
// Create dummy product - price will be 10.
$product = WC_Helper_Product::create_simple_product();
// Add product to cart x1, calc and test
// Add product to cart x1, calc and test.
WC()->cart->add_to_cart( $product->get_id(), 1 );
WC()->cart->calculate_totals();
$this->assertEquals( '9.00', number_format( WC()->cart->total, 2, '.', '' ) );
$this->assertEquals( '1.00', number_format( WC()->cart->discount_cart, 2, '.', '' ) );
// Add product to cart x2, calc and test
// Add product to cart x2, calc and test.
WC()->cart->add_to_cart( $product->get_id(), 1 );
WC()->cart->calculate_totals();
$this->assertEquals( '19.00', number_format( WC()->cart->total, 2, '.', '' ) );
$this->assertEquals( '1.00', number_format( WC()->cart->discount_cart, 2, '.', '' ) );
// Add product to cart x3, calc and test
// Add product to cart x3, calc and test.
WC()->cart->add_to_cart( $product->get_id(), 1 );
WC()->cart->calculate_totals();
$this->assertEquals( '29.00', number_format( WC()->cart->total, 2, '.', '' ) );
@ -336,10 +342,10 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* Ticket: https://github.com/woocommerce/woocommerce/issues/10573
*/
public function test_cart_get_discounted_price_issue_10573() {
// Create dummy coupon - fixed cart, 1 value
// Create dummy coupon - fixed cart, 1 value.
$coupon = WC_Helper_Coupon::create_coupon();
// Create dummy product - price will be 10
// Create dummy product - price will be 10.
$product = WC_Helper_Product::create_simple_product();
$product->set_regular_price( '29.95' );
@ -373,7 +379,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
/**
* Test that calculation rounding is done correctly with and without taxes.
*
* @see https://github.com/woocommerce/woocommerce/issues/16305
* @see https://github.com/woocommerce/woocommerce/issues/16305.
* @since 3.2
*/
public function test_discount_cart_rounding() {
@ -826,12 +832,11 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_total( 'edit' ), 2 ) );
}
/**
* Helper that can be hooked to a filter to force the customer's shipping country to be GB.
*
* @since 3.3
* @param string $country
* @param string $country Country code.
* @return string
*/
public function force_customer_gb_shipping( $country ) {
@ -842,7 +847,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* Helper that can be hooked to a filter to force the customer's shipping country to be US.
*
* @since 3.3
* @param string $country
* @param string $country Country code.
* @return string
*/
public function force_customer_us_shipping( $country ) {
@ -1135,13 +1140,13 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_get_remove_url() {
// Get the cart page id
// Get the cart page id.
$cart_page_url = wc_get_page_permalink( 'cart' );
// Test cart item key
// Test cart item key.
$cart_item_key = 'test';
// Do the check
// Do the check.
$this->assertEquals( apply_filters( 'woocommerce_get_remove_url', $cart_page_url ? wp_nonce_url( add_query_arg( 'remove_item', $cart_item_key, $cart_page_url ), 'woocommerce-cart' ) : '' ), wc_get_cart_remove_url( $cart_item_key ) );
}
@ -1151,13 +1156,13 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_add_to_cart_simple() {
// Create dummy product
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
// Add the product to the cart. Methods returns boolean on failure, string on success.
$this->assertNotFalse( WC()->cart->add_to_cart( $product->get_id(), 1 ) );
// Check if the item is in the cart
// Check if the item is in the cart.
$this->assertEquals( 1, WC()->cart->get_cart_contents_count() );
}
@ -1165,16 +1170,16 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* Check if we can add a trashed product to the cart.
*/
public function test_add_to_cart_trashed() {
// Create dummy product
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
// Trash product
// Trash product.
wp_trash_post( $product->get_id() );
// Refetch product, to be sure
// Refetch product, to be sure.
$product = wc_get_product( $product->get_id() );
// Add product to cart
// Add product to cart.
$this->assertFalse( WC()->cart->add_to_cart( $product->get_id(), 1 ) );
}
@ -1191,7 +1196,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
// Add the product to the cart. Methods returns boolean on failure, string on success.
$this->assertNotFalse( WC()->cart->add_to_cart( $product->get_id(), 1, $variation['variation_id'], array( 'Size' => ucfirst( $variation['attributes']['attribute_pa_size'] ) ) ) );
// Check if the item is in the cart
// Check if the item is in the cart.
$this->assertEquals( 1, WC()->cart->get_cart_contents_count() );
}
@ -1201,7 +1206,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_add_to_cart_sold_individually() {
// Create dummy product
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
$product->set_sold_individually( true );
@ -1210,7 +1215,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
// Add the product twice to cart, should be corrected to 1. Methods returns boolean on failure, string on success.
$this->assertNotFalse( WC()->cart->add_to_cart( $product->get_id(), 2 ) );
// Check if the item is in the cart
// Check if the item is in the cart.
$this->assertEquals( 1, WC()->cart->get_cart_contents_count() );
}
@ -1220,16 +1225,16 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_find_product_in_cart() {
// Create dummy product
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
// Add product to cart
// Add product to cart.
WC()->cart->add_to_cart( $product->get_id(), 1 );
// Generate cart id
// Generate cart id.
$cart_id = WC()->cart->generate_cart_id( $product->get_id() );
// Get the product from the cart
// Get the product from the cart.
$this->assertNotEquals( '', WC()->cart->find_product_in_cart( $cart_id ) );
}
@ -1239,8 +1244,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_generate_cart_id() {
// Setup data
// Setup data.
$product_id = 1;
$variation_id = 2;
$variation = array( 'Testing' => 'yup' );
@ -1254,7 +1258,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
),
);
// Manually generate ID
// Manually generate ID.
$id_parts = array( $product_id );
if ( $variation_id && 0 != $variation_id ) {
@ -1284,7 +1288,6 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$manual_cart_id = md5( implode( '_', $id_parts ) );
// Assert
$this->assertEquals( $manual_cart_id, WC()->cart->generate_cart_id( $product_id, $variation_id, array( 'Testing' => 'yup' ), $cart_item_data ) );
}
@ -1295,25 +1298,25 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_set_quantity() {
// Create dummy product
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
// Add 1 product to cart
// Add 1 product to cart.
WC()->cart->add_to_cart( $product->get_id(), 1 );
// Get cart id
// Get cart id.
$cart_id = WC()->cart->generate_cart_id( $product->get_id() );
// Set quantity of product in cart to 2
// Set quantity of product in cart to 2.
$this->assertTrue( WC()->cart->set_quantity( $cart_id, 2 ), $cart_id );
// Check if there are 2 items in cart now
// Check if there are 2 items in cart now.
$this->assertEquals( 2, WC()->cart->get_cart_contents_count() );
// Set quantity of product in cart to 0
// Set quantity of product in cart to 0.
$this->assertTrue( WC()->cart->set_quantity( $cart_id, 0 ) );
// Check if there are 0 items in cart now
// Check if there are 0 items in cart now.
$this->assertEquals( 0, WC()->cart->get_cart_contents_count() );
}
@ -1324,13 +1327,13 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
*/
public function test_check_cart_item_validity() {
// Create dummy product
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
// Add product to cart
// Add product to cart.
WC()->cart->add_to_cart( $product->get_id(), 1 );
// Check cart validity, should pass
// Check cart validity, should pass.
$this->assertTrue( WC()->cart->check_cart_item_validity() );
}
@ -1340,13 +1343,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_get_total() {
// Create dummy product
$product = WC_Helper_Product::create_simple_product();
// Add product to cart
WC()->cart->add_to_cart( $product->get_id(), 1 );
// Check
$this->assertEquals( apply_filters( 'woocommerce_cart_total', wc_price( WC()->cart->total ) ), WC()->cart->get_total() );
}
@ -1421,25 +1420,25 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* @since 2.3
*/
public function test_shipping_total() {
// Create product
// Create product.
$product = WC_Helper_Product::create_simple_product();
$product->set_regular_price( 10 );
$product->save();
// Create a flat rate method
// Create a flat rate method.
WC_Helper_Shipping::create_simple_flat_rate();
// Add product to cart
// Add product to cart.
WC()->cart->add_to_cart( $product->get_id(), 1 );
// Set the flat_rate shipping method
// Set the flat_rate shipping method.
WC()->session->set( 'chosen_shipping_methods', array( 'flat_rate' ) );
WC()->cart->calculate_totals();
// Test if the shipping total amount is equal 20
// Test if the shipping total amount is equal 20.
$this->assertEquals( 10, WC()->cart->shipping_total );
// Test if the cart total amount is equal 20
// Test if the cart total amount is equal 20.
$this->assertEquals( 20, WC()->cart->total );
}
@ -1583,10 +1582,10 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
* Test cart coupons.
*/
public function test_get_coupons() {
// Create coupon
// Create coupon.
$coupon = WC_Helper_Coupon::create_coupon();
// Add coupon
// Add coupon.
WC()->cart->add_discount( $coupon->get_code() );
$this->assertEquals( count( WC()->cart->get_coupons() ), 1 );
@ -1611,6 +1610,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertFalse( $success );
}
/**
* test_add_invidual_use_coupon.
*/
public function test_add_invidual_use_coupon() {
$iu_coupon = WC_Helper_Coupon::create_coupon( 'code1' );
$iu_coupon->set_individual_use( true );
@ -1626,6 +1628,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( 'code1', reset( $coupons )->get_code() );
}
/**
* test_add_individual_use_coupon_removal.
*/
public function test_add_individual_use_coupon_removal() {
$coupon = WC_Helper_Coupon::create_coupon();
$iu_coupon = WC_Helper_Coupon::create_coupon( 'code1' );
@ -1642,6 +1647,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( 1, did_action( 'woocommerce_removed_coupon' ) );
}
/**
* test_add_individual_use_coupon_double_individual.
*/
public function test_add_individual_use_coupon_double_individual() {
$iu_coupon1 = WC_Helper_Coupon::create_coupon( 'code1' );
$iu_coupon1->set_individual_use( true );
@ -1660,6 +1668,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( 'code2', reset( $coupons )->get_code() );
}
/**
* test_clone_cart.
*/
public function test_clone_cart() {
$cart = wc()->cart;
$new_cart = clone $cart;
@ -1669,6 +1680,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertFalse( $is_identical_cart, 'Cloned cart not identical to original cart' );
}
/**
* test_cloned_cart_session.
*/
public function test_cloned_cart_session() {
// PHP 5.2 does not include support for ReflectionProperty::setAccessible().
if ( version_compare( '5.3', PHP_VERSION, '>' ) ) {
@ -1691,6 +1705,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertFalse( $identical_sessions, 'Cloned cart sessions should not be identical to original cart' );
}
/**
* test_cloned_cart_fees.
*/
public function test_cloned_cart_fees() {
$cart = wc()->cart;
$new_cart = clone $cart;
@ -1704,11 +1721,17 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertFalse( $identical_fees, 'Cloned cart fees should not be identical to original cart.' );
}
/**
* test_cart_object_istantiation.
*/
public function test_cart_object_istantiation() {
$cart = new WC_Cart();
$this->assertInstanceOf( 'WC_Cart', $cart );
}
/**
* test_get_cart_item_quantities.
*/
public function test_get_cart_item_quantities() {
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
@ -1716,6 +1739,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( 1, array_sum( WC()->cart->get_cart_item_quantities() ) );
}
/**
* test_get_cart_contents_weight.
*/
public function test_get_cart_contents_weight() {
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
@ -1723,6 +1749,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( 1.1, WC()->cart->get_cart_contents_weight() );
}
/**
* test_check_cart_items.
*/
public function test_check_cart_items() {
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
@ -1730,6 +1759,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( true, WC()->cart->check_cart_items() );
}
/**
* test_check_cart_item_stock.
*/
public function test_check_cart_item_stock() {
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
@ -1737,6 +1769,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( true, WC()->cart->check_cart_item_stock() );
}
/**
* test_get_cross_sells.
*/
public function test_get_cross_sells() {
// Create dummy product.
$product = WC_Helper_Product::create_simple_product();
@ -1744,6 +1779,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( array(), WC()->cart->get_cross_sells() );
}
/**
* test_get_tax_totals.
*/
public function test_get_tax_totals() {
// Set calc taxes option.
update_option( 'woocommerce_calc_taxes', 'yes' );
@ -1799,4 +1837,71 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
$this->assertEquals( true, WC()->cart->is_coupon_emails_allowed( array( 'customer@wc.local' ), array( 'customer@wc.local' ) ) );
$this->assertEquals( false, WC()->cart->is_coupon_emails_allowed( array( 'customer@wc.local' ), array( 'customer2@wc.local' ) ) );
}
/**
* Check subtotals align when using filters. Ref: 23340
*/
public function test_changing_tax_class_via_filter_issue_23340() {
// Store is set to enter product prices inclusive tax.
update_option( 'woocommerce_prices_include_tax', 'yes' );
update_option( 'woocommerce_calc_taxes', 'yes' );
// 5% tax.
$tax_rate = array(
'tax_rate_country' => '',
'tax_rate_state' => '',
'tax_rate' => '5.0000',
'tax_rate_name' => 'VAT',
'tax_rate_priority' => '1',
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
'tax_rate_class' => '',
);
WC_Tax::_insert_tax_rate( $tax_rate );
// 20% tax.
$tax_rate = array(
'tax_rate_country' => '',
'tax_rate_state' => '',
'tax_rate' => '20.0000',
'tax_rate_name' => 'VAT',
'tax_rate_priority' => '1',
'tax_rate_compound' => '0',
'tax_rate_shipping' => '1',
'tax_rate_order' => '1',
'tax_rate_class' => 'reduced-rate',
);
WC_Tax::_insert_tax_rate( $tax_rate );
// Create products and add them to cart.
$product1 = new WC_Product_Simple();
$product1->set_regular_price( '6' );
$product1->save();
WC()->cart->add_to_cart( $product1->get_id(), 1 );
WC()->cart->calculate_totals();
$this->assertEquals( '5.71', WC()->cart->get_subtotal() );
$this->assertEquals( '6', WC()->cart->get_total( 'edit' ) );
add_filter( 'woocommerce_product_get_tax_class', array( $this, 'change_tax_class_filter' ) );
add_filter( 'woocommerce_product_variation_get_tax_class', array( $this, 'change_tax_class_filter' ) );
WC()->cart->calculate_totals();
$this->assertEquals( '5.71', WC()->cart->get_subtotal() );
$this->assertEquals( '6.85', WC()->cart->get_total( 'edit' ) );
remove_filter( 'woocommerce_product_get_tax_class', array( $this, 'change_tax_class_filter' ) );
remove_filter( 'woocommerce_product_variation_get_tax_class', array( $this, 'change_tax_class_filter' ) );
}
/**
* Change tax class.
*
* @return string
*/
public function change_tax_class_filter() {
return 'reduced-rate';
}
}

View File

@ -1,9 +1,12 @@
<?php
/**
* Test for the discounts class.
* @package WooCommerce\Tests\Discounts
*/
/**
* WC_Tests_Discounts.
*/
class WC_Tests_Discounts extends WC_Unit_Test_Case {
/**
@ -30,7 +33,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
* Helper function to hold a reference to created coupon objects so they
* can be cleaned up properly at the end of each test.
*
* @param $coupon WC_Coupon The coupon object to store.
* @param WC_Coupon $coupon The coupon object to store.
*/
protected function store_coupon( $coupon ) {
$this->coupons[ $coupon->get_code() ] = $coupon;
@ -40,7 +43,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
* Helper function to hold a reference to created product objects so they
* can be cleaned up properly at the end of each test.
*
* @param $product WC_Product The product object to store.
* @param WC_Product $product The product object to store.
*/
protected function store_product( $product ) {
$this->products[] = $product;
@ -50,12 +53,15 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
* Helper function to hold a reference to created order objects so they
* can be cleaned up properly at the end of each test.
*
* @param $order WC_Order The order object to store.
* @param WC_Order $order The order object to store.
*/
protected function store_order( $order ) {
$this->orders[] = $order;
}
/**
* Setup tests.
*/
public function setUp() {
parent::setUp();
@ -79,7 +85,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
* Test get and set items.
*/
public function test_get_set_items_from_cart() {
// Create dummy product - price will be 10
// Create dummy product - price will be 10.
$product = WC_Helper_Product::create_simple_product();
$this->store_product( $product );
@ -1336,6 +1342,9 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
);
}
/**
* test_free_shipping_coupon_no_products.
*/
public function test_free_shipping_coupon_no_products() {
$discounts = new WC_Discounts();
$coupon = WC_Helper_Coupon::create_coupon( 'freeshipping' );
@ -1353,10 +1362,18 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
$this->assertEquals( 0, count( $all_discounts['freeshipping'] ), 'Free shipping coupon should not have any discounts.' );
}
/**
* filter_woocommerce_coupon_get_discount_amount.
*
* @param float $discount Discount amount.
*/
public function filter_woocommerce_coupon_get_discount_amount( $discount ) {
return $discount / 2;
}
/**
* test_coupon_discount_amount_filter.
*/
public function test_coupon_discount_amount_filter() {
$discounts = new WC_Discounts();
@ -1516,8 +1533,6 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
/**
* Test the per product coupon logic with and without sale items.
*
* @since 3.4.6
*/
public function test_is_coupon_valid_fixed_product_sale_items() {
$product_no_sale = new WC_Product_Simple();

View File

@ -1,8 +1,12 @@
<?php
/**
* Class WC_Product_CSV_Importer unit tests.
*
* @package WooCommerce\Tests\Importer
*/
/**
* Meta
* @package WooCommerce\Tests\Importer
* Test class for WC_Product_CSV_Importer.
*/
class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
@ -107,6 +111,36 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
$this->assertEquals( 0, count( $results['skipped'] ) );
}
/**
* Test import should update product price and skip products with empty SKU
* (see https://github.com/woocommerce/woocommerce/issues/23257).
*/
public function test_import_should_update_product() {
$product = WC_Helper_Product::create_simple_product();
$product->set_price( 15 );
$product->set_sku( 'wp-pennant' );
$product->save();
$args = array(
'mapping' => $this->get_csv_mapped_items(),
'parse' => true,
'update_existing' => true,
);
$csv_file = dirname( __FILE__ ) . '/sample_update_product.csv';
$importer = new WC_Product_CSV_Importer( $csv_file, $args );
$results = $importer->import();
$this->assertEquals( 0, count( $results['imported'] ) );
$this->assertEquals( 0, count( $results['failed'] ) );
$this->assertEquals( 1, count( $results['updated'] ) );
$this->assertEquals( 2, count( $results['skipped'] ) );
$updated_product = wc_get_product( $product->get_id() );
$this->assertEquals( 20, $updated_product->get_price() );
}
/**
* Test importing file located on another location on server.
*

View File

@ -0,0 +1,4 @@
Name,SKU,Regular price
WordPress Pennant,wp-pennant,20
0,,something invalid
0,,something invalid
1 Name SKU Regular price
2 WordPress Pennant wp-pennant 20
3 0 something invalid
4 0 something invalid

View File

@ -17,7 +17,7 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
$shortcode = new WC_Shortcode_Products();
$expected = array(
'limit' => '-1',
'columns' => '4',
'columns' => 4,
'orderby' => 'title',
'order' => 'ASC',
'ids' => '',
@ -27,6 +27,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'attribute' => '',
'terms' => '',
'terms_operator' => 'IN',
'tag' => '',
'tag_operator' => 'IN',
'visibility' => 'visible',
'class' => '',
'rows' => '',
@ -55,6 +57,8 @@ class WC_Test_Shortcode_Products extends WC_Unit_Test_Case {
'attribute' => '',
'terms' => '',
'terms_operator' => 'IN',
'tag' => '',
'tag_operator' => 'IN',
'visibility' => 'visible',
'class' => '',
'rows' => '',