Merge branch 'master' into update/19061
This commit is contained in:
commit
eb26221b1a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -13,6 +13,9 @@ body {
|
|||
max-width: 30%;
|
||||
}
|
||||
}
|
||||
.wc-setup {
|
||||
text-align: center;
|
||||
}
|
||||
.wc-setup-content {
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
|
||||
padding: 2em;
|
||||
|
@ -20,6 +23,7 @@ body {
|
|||
background: #fff;
|
||||
overflow: hidden;
|
||||
zoom: 1;
|
||||
text-align: left;
|
||||
|
||||
h1, h2, h3, table {
|
||||
margin: 0 0 20px;
|
||||
|
@ -297,7 +301,6 @@ body {
|
|||
}
|
||||
}
|
||||
.woocommerce-newsletter,
|
||||
.woocommerce-tracker,
|
||||
.updated {
|
||||
padding: 24px 24px 0;
|
||||
margin: 0 0 24px;
|
||||
|
@ -312,9 +315,74 @@ body {
|
|||
margin: 0 0 24px;
|
||||
}
|
||||
}
|
||||
.woocommerce-tracker + .woocommerce-newsletter {
|
||||
margin-top: -24px;
|
||||
border-top: 2px dashed #ddd;
|
||||
.woocommerce-tracker {
|
||||
margin: 24px 0;
|
||||
border: 1px solid #eee;
|
||||
padding: 20px;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
.checkbox {
|
||||
line-height: 24px;
|
||||
font-weight: 500;
|
||||
font-size: 1em;
|
||||
margin-top: 0;
|
||||
margin-bottom: 20px;
|
||||
|
||||
input[type="checkbox"] {
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
}
|
||||
label {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
padding-left: 28px;
|
||||
&:before,
|
||||
&:after {
|
||||
position: absolute;
|
||||
content: "";
|
||||
display: inline-block;
|
||||
}
|
||||
&:before {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
left: 0px;
|
||||
top: 3px;
|
||||
border: 1px solid #aaa;
|
||||
background-color: #fff;
|
||||
border-radius: 3px;
|
||||
}
|
||||
&:after {
|
||||
height: 5px;
|
||||
width: 9px;
|
||||
border-left: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
transform: rotate(-45deg);
|
||||
left: 4px;
|
||||
top: 7px;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
input[type="checkbox"] + label::after {
|
||||
content: none;
|
||||
}
|
||||
input[type="checkbox"]:checked + label::after {
|
||||
content: "";
|
||||
}
|
||||
input[type="checkbox"]:focus + label::before {
|
||||
outline: rgb(59, 153, 252) auto 5px;
|
||||
}
|
||||
input[type="checkbox"]:checked + label::before {
|
||||
background: #935687;
|
||||
border-color: #935687;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.wc-setup-steps {
|
||||
|
@ -417,8 +485,8 @@ body {
|
|||
.wc-setup-footer-links {
|
||||
font-size: 0.85em;
|
||||
color: #b5b5b5;
|
||||
margin: 1.18em 0;
|
||||
display: block;
|
||||
margin: 1.18em auto;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -828,11 +896,21 @@ h3.jetpack-reasons {
|
|||
font-size: 14px;
|
||||
}
|
||||
|
||||
.jetpack-logo {
|
||||
.jetpack-logo, .wcs-notice {
|
||||
display: block;
|
||||
margin: 1.75em auto 2em auto;
|
||||
max-height: 175px;
|
||||
}
|
||||
.activate-splash {
|
||||
.jetpack-logo {
|
||||
width: 170px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.wcs-notice {
|
||||
margin-top: 1em;
|
||||
padding-left: 57px;
|
||||
}
|
||||
}
|
||||
|
||||
.step {
|
||||
text-align: center;
|
||||
|
@ -1072,15 +1150,6 @@ p.jetpack-terms {
|
|||
}
|
||||
}
|
||||
|
||||
.allow-tracking {
|
||||
color: #9f9f9f;
|
||||
margin-top: 1em;
|
||||
text-align: center;
|
||||
font-size: 0.9em;
|
||||
padding-top: 2em;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.wc-wizard-service-setting-stripe_create_account, .wc-wizard-service-setting-ppec_paypal_reroute_requests {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
|
@ -112,9 +112,6 @@ jQuery( function ( $ ) {
|
|||
|
||||
if ( ! $country_input.val() ) {
|
||||
$country_input.val( woocommerce_admin_meta_boxes_order.default_country ).change();
|
||||
}
|
||||
|
||||
if ( ! $state_input.val() ) {
|
||||
$state_input.val( woocommerce_admin_meta_boxes_order.default_state ).change();
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -42,7 +42,7 @@
|
|||
setTimeout( function() {
|
||||
$form.trigger( 'check_variations' );
|
||||
$form.trigger( 'wc_variation_form' );
|
||||
$form.loading = loading;
|
||||
$form.loading = false;
|
||||
}, 100 );
|
||||
};
|
||||
|
||||
|
@ -565,8 +565,9 @@
|
|||
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
|
||||
|
||||
if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
|
||||
if ( $gallery_nav.find( 'li img[src="' + variation.image.thumb_src + '"]' ).length > 0 ) {
|
||||
$gallery_nav.find( 'li img[src="' + variation.image.thumb_src + '"]' ).trigger( 'click' );
|
||||
if ( $gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).length > 0 ) {
|
||||
$form.wc_variations_image_reset();
|
||||
$gallery_nav.find( 'li img[src="' + variation.image.gallery_thumbnail_src + '"]' ).trigger( 'click' );
|
||||
$form.attr( 'current-image', variation.image_id );
|
||||
return;
|
||||
} else {
|
||||
|
@ -582,24 +583,11 @@
|
|||
$product_img.wc_set_variation_attr( 'data-large_image_width', variation.image.full_src_w );
|
||||
$product_img.wc_set_variation_attr( 'data-large_image_height', variation.image.full_src_h );
|
||||
$product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
|
||||
$gallery_img.wc_set_variation_attr( 'src', variation.image.thumb_src );
|
||||
$gallery_img.wc_set_variation_attr( 'src', variation.image.gallery_thumbnail_src );
|
||||
$product_link.wc_set_variation_attr( 'href', variation.image.full_src );
|
||||
}
|
||||
} else {
|
||||
$product_img.wc_reset_variation_attr( 'src' );
|
||||
$product_img.wc_reset_variation_attr( 'width' );
|
||||
$product_img.wc_reset_variation_attr( 'height' );
|
||||
$product_img.wc_reset_variation_attr( 'srcset' );
|
||||
$product_img.wc_reset_variation_attr( 'sizes' );
|
||||
$product_img.wc_reset_variation_attr( 'title' );
|
||||
$product_img.wc_reset_variation_attr( 'alt' );
|
||||
$product_img.wc_reset_variation_attr( 'data-src' );
|
||||
$product_img.wc_reset_variation_attr( 'data-large_image' );
|
||||
$product_img.wc_reset_variation_attr( 'data-large_image_width' );
|
||||
$product_img.wc_reset_variation_attr( 'data-large_image_height' );
|
||||
$product_img_wrap.wc_reset_variation_attr( 'data-thumb' );
|
||||
$gallery_img.wc_reset_variation_attr( 'src' );
|
||||
$product_link.wc_reset_variation_attr( 'href' );
|
||||
$form.wc_variations_image_reset();
|
||||
}
|
||||
|
||||
window.setTimeout( function() {
|
||||
|
@ -609,6 +597,35 @@
|
|||
}, 20 );
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset main image to defaults.
|
||||
*/
|
||||
$.fn.wc_variations_image_reset = function() {
|
||||
var $form = this,
|
||||
$product = $form.closest( '.product' ),
|
||||
$product_gallery = $product.find( '.images' ),
|
||||
$gallery_nav = $product.find( '.flex-control-nav' ),
|
||||
$gallery_img = $gallery_nav.find( 'li:eq(0) img' ),
|
||||
$product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
|
||||
$product_img = $product_img_wrap.find( '.wp-post-image' ),
|
||||
$product_link = $product_img_wrap.find( 'a' ).eq( 0 );
|
||||
|
||||
$product_img.wc_reset_variation_attr( 'src' );
|
||||
$product_img.wc_reset_variation_attr( 'width' );
|
||||
$product_img.wc_reset_variation_attr( 'height' );
|
||||
$product_img.wc_reset_variation_attr( 'srcset' );
|
||||
$product_img.wc_reset_variation_attr( 'sizes' );
|
||||
$product_img.wc_reset_variation_attr( 'title' );
|
||||
$product_img.wc_reset_variation_attr( 'alt' );
|
||||
$product_img.wc_reset_variation_attr( 'data-src' );
|
||||
$product_img.wc_reset_variation_attr( 'data-large_image' );
|
||||
$product_img.wc_reset_variation_attr( 'data-large_image_width' );
|
||||
$product_img.wc_reset_variation_attr( 'data-large_image_height' );
|
||||
$product_img_wrap.wc_reset_variation_attr( 'data-thumb' );
|
||||
$gallery_img.wc_reset_variation_attr( 'src' );
|
||||
$product_link.wc_reset_variation_attr( 'href' );
|
||||
};
|
||||
|
||||
$(function() {
|
||||
if ( typeof wc_add_to_cart_variation_params !== 'undefined' ) {
|
||||
$( '.variations_form' ).each( function() {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5465,12 +5465,11 @@ S2.define('select2/core',[
|
|||
$(document).on('keydown', function (evt) {
|
||||
var key = evt.which;
|
||||
if (self.isOpen()) {
|
||||
if (key === KEYS.ESC || key === KEYS.TAB ||
|
||||
(key === KEYS.UP && evt.altKey)) {
|
||||
if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) {
|
||||
self.close();
|
||||
|
||||
evt.preventDefault();
|
||||
} else if (key === KEYS.ENTER) {
|
||||
} else if (key === KEYS.ENTER || key === KEYS.TAB) {
|
||||
self.trigger('results:select', {});
|
||||
|
||||
evt.preventDefault();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -5465,12 +5465,11 @@ S2.define('select2/core',[
|
|||
$(document).on('keydown', function (evt) {
|
||||
var key = evt.which;
|
||||
if (self.isOpen()) {
|
||||
if (key === KEYS.ESC || key === KEYS.TAB ||
|
||||
(key === KEYS.UP && evt.altKey)) {
|
||||
if (key === KEYS.ESC || (key === KEYS.UP && evt.altKey)) {
|
||||
self.close();
|
||||
|
||||
evt.preventDefault();
|
||||
} else if (key === KEYS.ENTER) {
|
||||
} else if (key === KEYS.ENTER || key === KEYS.TAB) {
|
||||
self.trigger('results:select', {});
|
||||
|
||||
evt.preventDefault();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -110,7 +110,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
|||
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
|
||||
wp_register_script( 'wc-clipboard', WC()->plugin_url() . '/assets/js/admin/wc-clipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION );
|
||||
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.3' );
|
||||
wp_register_script( 'selectWoo', WC()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.4' );
|
||||
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), WC_VERSION );
|
||||
wp_localize_script(
|
||||
'wc-enhanced-select',
|
||||
|
|
|
@ -2,15 +2,10 @@
|
|||
/**
|
||||
* Init WooCommerce data importers.
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 3.1.0
|
||||
* @package WooCommerce/Admin
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_Importers Class.
|
||||
|
@ -111,7 +106,6 @@ class WC_Admin_Importers {
|
|||
* The tax rate importer which extends WP_Importer.
|
||||
*/
|
||||
public function tax_rates_importer() {
|
||||
// Load Importer API
|
||||
require_once ABSPATH . 'wp-admin/includes/import.php';
|
||||
|
||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||
|
@ -122,10 +116,8 @@ class WC_Admin_Importers {
|
|||
}
|
||||
}
|
||||
|
||||
// includes
|
||||
require dirname( __FILE__ ) . '/importers/class-wc-tax-rate-importer.php';
|
||||
|
||||
// Dispatch
|
||||
$importer = new WC_Tax_Rate_Importer();
|
||||
$importer->dispatch();
|
||||
}
|
||||
|
@ -139,11 +131,11 @@ class WC_Admin_Importers {
|
|||
public function post_importer_compatibility() {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $_POST['import_id'] ) || ! class_exists( 'WXR_Parser' ) ) {
|
||||
if ( empty( $_POST['import_id'] ) || ! class_exists( 'WXR_Parser' ) ) { // PHPCS: input var ok, CSRF ok.
|
||||
return;
|
||||
}
|
||||
|
||||
$id = absint( $_POST['import_id'] );
|
||||
$id = absint( $_POST['import_id'] ); // PHPCS: input var ok.
|
||||
$file = get_attached_file( $id );
|
||||
$parser = new WXR_Parser();
|
||||
$import_data = $parser->parse( $file );
|
||||
|
@ -156,8 +148,8 @@ class WC_Admin_Importers {
|
|||
if ( ! taxonomy_exists( $term['domain'] ) ) {
|
||||
$attribute_name = wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $term['domain'] ) );
|
||||
|
||||
// Create the taxonomy
|
||||
if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies() ) ) {
|
||||
// Create the taxonomy.
|
||||
if ( ! in_array( $attribute_name, wc_get_attribute_taxonomies(), true ) ) {
|
||||
wc_create_attribute(
|
||||
array(
|
||||
'name' => $attribute_name,
|
||||
|
@ -198,19 +190,19 @@ class WC_Admin_Importers {
|
|||
|
||||
check_ajax_referer( 'wc-product-import', 'security' );
|
||||
|
||||
if ( ! current_user_can( 'edit_products' ) || ! isset( $_POST['file'] ) ) {
|
||||
if ( ! current_user_can( 'edit_products' ) || ! isset( $_POST['file'] ) ) { // PHPCS: input var ok.
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
||||
include_once WC_ABSPATH . 'includes/admin/importers/class-wc-product-csv-importer-controller.php';
|
||||
include_once WC_ABSPATH . 'includes/import/class-wc-product-csv-importer.php';
|
||||
|
||||
$file = wc_clean( $_POST['file'] );
|
||||
$file = wc_clean( wp_unslash( $_POST['file'] ) ); // PHPCS: input var ok.
|
||||
$params = array(
|
||||
'delimiter' => ! empty( $_POST['delimiter'] ) ? wc_clean( $_POST['delimiter'] ) : ',',
|
||||
'start_pos' => isset( $_POST['position'] ) ? absint( $_POST['position'] ) : 0,
|
||||
'mapping' => isset( $_POST['mapping'] ) ? (array) $_POST['mapping'] : array(),
|
||||
'update_existing' => isset( $_POST['update_existing'] ) ? (bool) $_POST['update_existing'] : false,
|
||||
'delimiter' => ! empty( $_POST['delimiter'] ) ? wc_clean( wp_unslash( $_POST['delimiter'] ) ) : ',', // PHPCS: input var ok.
|
||||
'start_pos' => isset( $_POST['position'] ) ? absint( $_POST['position'] ) : 0, // PHPCS: input var ok.
|
||||
'mapping' => isset( $_POST['mapping'] ) ? (array) wc_clean( wp_unslash( $_POST['mapping'] ) ) : array(), // PHPCS: input var ok.
|
||||
'update_existing' => isset( $_POST['update_existing'] ) ? (bool) $_POST['update_existing'] : false, // PHPCS: input var ok.
|
||||
'lines' => apply_filters( 'woocommerce_product_import_batch_size', 30 ),
|
||||
'parse' => true,
|
||||
);
|
||||
|
@ -231,7 +223,7 @@ class WC_Admin_Importers {
|
|||
|
||||
if ( 100 === $percent_complete ) {
|
||||
// Clear temp meta.
|
||||
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) );
|
||||
$wpdb->delete( $wpdb->postmeta, array( 'meta_key' => '_original_id' ) ); // @codingStandardsIgnoreLine.
|
||||
$wpdb->query(
|
||||
"DELETE {$wpdb->posts}, {$wpdb->postmeta}, {$wpdb->term_relationships}
|
||||
FROM {$wpdb->posts}
|
||||
|
@ -243,6 +235,14 @@ class WC_Admin_Importers {
|
|||
AND {$wpdb->posts}.post_status = 'importing'"
|
||||
);
|
||||
|
||||
// Clear orphan variations.
|
||||
$wpdb->query(
|
||||
"DELETE products
|
||||
FROM {$wpdb->posts} products
|
||||
LEFT JOIN {$wpdb->posts} wp ON wp.ID = products.post_parent
|
||||
WHERE wp.ID IS NULL AND products.post_type = 'product_variation';"
|
||||
);
|
||||
|
||||
// Send success.
|
||||
wp_send_json_success(
|
||||
array(
|
||||
|
|
|
@ -171,12 +171,6 @@ class WC_Admin_Setup_Wizard {
|
|||
unset( $default_steps['shipping'] );
|
||||
}
|
||||
|
||||
// Hide the activate step if Jetpack is already active, but not
|
||||
// if we're returning from connecting Jetpack on WordPress.com.
|
||||
if ( class_exists( 'Jetpack' ) && Jetpack::is_active() && ! isset( $_GET['from'] ) && ! isset( $_GET['activate_error'] ) ) { // WPCS: CSRF ok, input var ok.
|
||||
unset( $default_steps['activate'] );
|
||||
}
|
||||
|
||||
// Whether or not there is a pending background install of Jetpack.
|
||||
$pending_jetpack = ! class_exists( 'Jetpack' ) && get_option( 'woocommerce_setup_background_installing_jetpack' );
|
||||
|
||||
|
@ -298,9 +292,18 @@ class WC_Admin_Setup_Wizard {
|
|||
* Output the steps.
|
||||
*/
|
||||
public function setup_wizard_steps() {
|
||||
$output_steps = $this->steps;
|
||||
$selected_features = array_filter( $this->wc_setup_activate_get_feature_list() );
|
||||
|
||||
// Hide the activate step if Jetpack is already active, unless WooCommerce Services
|
||||
// features are selected, or unless the Activate step was already taken.
|
||||
if ( class_exists( 'Jetpack' ) && Jetpack::is_active() && empty( $selected_features ) && 'yes' !== get_transient( 'wc_setup_activated' ) ) {
|
||||
unset( $output_steps['activate'] );
|
||||
}
|
||||
|
||||
?>
|
||||
<ol class="wc-setup-steps">
|
||||
<?php foreach ( $this->steps as $step_key => $step ) :
|
||||
<?php foreach ( $output_steps as $step_key => $step ) :
|
||||
$is_completed = array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true );
|
||||
|
||||
if ( $step_key === $this->step ) : ?>
|
||||
|
@ -477,9 +480,17 @@ class WC_Admin_Setup_Wizard {
|
|||
</label>
|
||||
|
||||
<?php if ( 'unknown' === get_option( 'woocommerce_allow_tracking', 'unknown' ) ) : ?>
|
||||
<div class="allow-tracking">
|
||||
<input type="checkbox" id="wc_tracker_optin" name="wc_tracker_optin" value="yes" checked />
|
||||
<label for="wc_tracker_optin"><?php esc_html_e( 'Allow WooCommerce to collect non-sensitive diagnostic data and usage information.', 'woocommerce' ); ?></label>
|
||||
<div class="woocommerce-tracker">
|
||||
<p class="checkbox">
|
||||
<input type="checkbox" id="wc_tracker_optin" name="wc_tracker_optin" value="yes" checked />
|
||||
<label for="wc_tracker_optin"><?php esc_html_e( 'Help WooCommerce improve by enabling usage tracking.', 'woocommerce' ); ?></label>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
esc_html_e( 'Checking this box means making WooCommerce better — your store will be considered as we evaluate new features, judge the quality of an update, or determine if an improvement makes sense. If you do not check this box, we will not know this store exists and we will not collect any usage data.', 'woocommerce' );
|
||||
echo ' <a target="_blank" href="https://woocommerce.com/usage-tracking/">' . esc_html__( 'Read more about what we collect.', 'woocommerce' ) . '</a>';
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<p class="wc-setup-actions step">
|
||||
|
@ -1675,8 +1686,9 @@ class WC_Admin_Setup_Wizard {
|
|||
}
|
||||
}
|
||||
|
||||
protected function wc_setup_activate_get_description() {
|
||||
$description = false;
|
||||
protected function wc_setup_activate_get_feature_list() {
|
||||
$features = array();
|
||||
|
||||
$stripe_settings = get_option( 'woocommerce_stripe_settings', false );
|
||||
$stripe_enabled = is_array( $stripe_settings )
|
||||
&& isset( $stripe_settings['create_account'] ) && 'yes' === $stripe_settings['create_account']
|
||||
|
@ -1685,32 +1697,35 @@ class WC_Admin_Setup_Wizard {
|
|||
$ppec_enabled = is_array( $ppec_settings )
|
||||
&& isset( $ppec_settings['reroute_requests'] ) && 'yes' === $ppec_settings['reroute_requests']
|
||||
&& isset( $ppec_settings['enabled'] ) && 'yes' === $ppec_settings['enabled'];
|
||||
$payment_enabled = $stripe_enabled || $ppec_enabled;
|
||||
$taxes_enabled = (bool) get_option( 'woocommerce_setup_automated_taxes', false );
|
||||
$features['payment'] = $stripe_enabled || $ppec_enabled;
|
||||
|
||||
$features['taxes'] = (bool) get_option( 'woocommerce_setup_automated_taxes', false );
|
||||
|
||||
$domestic_rates = (bool) get_option( 'woocommerce_setup_domestic_live_rates_zone', false );
|
||||
$intl_rates = (bool) get_option( 'woocommerce_setup_intl_live_rates_zone', false );
|
||||
$rates_enabled = $domestic_rates || $intl_rates;
|
||||
$features['rates'] = $domestic_rates || $intl_rates;
|
||||
|
||||
/* translators: %s: list of features, potentially comma separated */
|
||||
$description_base = __( 'Your store is almost ready! To activate services like %s, just connect with Jetpack.', 'woocommerce' );
|
||||
return $features;
|
||||
}
|
||||
|
||||
if ( $payment_enabled && $taxes_enabled && $rates_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'payment setup, automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
|
||||
} else if ( $payment_enabled && $taxes_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'payment setup and automated taxes', 'woocommerce' ) );
|
||||
} else if ( $payment_enabled && $rates_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'payment setup, live rates and discounted shipping labels', 'woocommerce' ) );
|
||||
} else if ( $payment_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'payment setup', 'woocommerce' ) );
|
||||
} else if ( $taxes_enabled && $rates_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'automated taxes, live rates and discounted shipping labels', 'woocommerce' ) );
|
||||
} else if ( $taxes_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'automated taxes', 'woocommerce' ) );
|
||||
} else if ( $rates_enabled ) {
|
||||
$description = sprintf( $description_base, __( 'live rates and discounted shipping labels', 'woocommerce' ) );
|
||||
protected function wc_setup_activate_get_feature_list_str() {
|
||||
$features = $this->wc_setup_activate_get_feature_list();
|
||||
if ( $features['payment'] && $features['taxes'] && $features['rates'] ) {
|
||||
return __( 'payment setup, automated taxes, live rates and discounted shipping labels', 'woocommerce' );
|
||||
} else if ( $features['payment'] && $features['taxes'] ) {
|
||||
return __( 'payment setup and automated taxes', 'woocommerce' );
|
||||
} else if ( $features['payment'] && $features['rates'] ) {
|
||||
return __( 'payment setup, live rates and discounted shipping labels', 'woocommerce' );
|
||||
} else if ( $features['payment'] ) {
|
||||
return __( 'payment setup', 'woocommerce' );
|
||||
} else if ( $features['taxes'] && $features['rates'] ) {
|
||||
return __( 'automated taxes, live rates and discounted shipping labels', 'woocommerce' );
|
||||
} else if ( $features['taxes'] ) {
|
||||
return __( 'automated taxes', 'woocommerce' );
|
||||
} else if ( $features['rates'] ) {
|
||||
return __( 'live rates and discounted shipping labels', 'woocommerce' );
|
||||
}
|
||||
|
||||
return $description;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1719,6 +1734,8 @@ class WC_Admin_Setup_Wizard {
|
|||
public function wc_setup_activate() {
|
||||
$this->wc_setup_activate_actions();
|
||||
|
||||
$jetpack_connected = class_exists( 'Jetpack' ) && Jetpack::is_active();
|
||||
|
||||
$has_jetpack_error = false;
|
||||
if ( isset( $_GET['activate_error'] ) ) {
|
||||
$has_jetpack_error = true;
|
||||
|
@ -1728,19 +1745,57 @@ class WC_Admin_Setup_Wizard {
|
|||
$error_message = $this->get_activate_error_message( sanitize_text_field( wp_unslash( $_GET['activate_error'] ) ) );
|
||||
$description = $error_message;
|
||||
} else {
|
||||
$description = $this->wc_setup_activate_get_description();
|
||||
$title = $description ?
|
||||
__( 'Connect your store to Jetpack', 'woocommerce' ) :
|
||||
__( 'Connect your store to Jetpack to enable extra features', 'woocommerce' );
|
||||
$feature_list = $this->wc_setup_activate_get_feature_list_str();
|
||||
|
||||
$description = false;
|
||||
|
||||
if ( $feature_list ) {
|
||||
if ( ! $jetpack_connected ) {
|
||||
/* translators: %s: list of features, potentially comma separated */
|
||||
$description_base = __( 'Your store is almost ready! To activate services like %s, just connect with Jetpack.', 'woocommerce' );
|
||||
} else {
|
||||
$description_base = __( 'Thanks for using Jetpack! Your store is almost ready: to activate services like %s, just connect your store.', 'woocommerce' );
|
||||
}
|
||||
$description = sprintf( $description_base, $feature_list );
|
||||
}
|
||||
|
||||
if ( ! $jetpack_connected ) {
|
||||
$title = $feature_list ?
|
||||
__( 'Connect your store to Jetpack', 'woocommerce' ) :
|
||||
__( 'Connect your store to Jetpack to enable extra features', 'woocommerce' );
|
||||
$button_text = __( 'Continue with Jetpack', 'woocommerce' );
|
||||
} elseif ( $feature_list ) {
|
||||
$title = __( 'Connect your store to activate WooCommerce Services', 'woocommerce' );
|
||||
$button_text = __( 'Continue with WooCommerce Services', 'woocommerce' );
|
||||
} else {
|
||||
wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h1><?php echo esc_html( $title ); ?></h1>
|
||||
<p><?php echo esc_html( $description ); ?></p>
|
||||
<img
|
||||
class="jetpack-logo"
|
||||
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_vertical_logo.png' ); ?>"
|
||||
alt="Jetpack logo"
|
||||
/>
|
||||
|
||||
<?php if ( $jetpack_connected ) : ?>
|
||||
<div class="activate-splash">
|
||||
<img
|
||||
class="jetpack-logo"
|
||||
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_horizontal_logo.png' ); ?>"
|
||||
alt="Jetpack logo"
|
||||
/>
|
||||
<img
|
||||
class="wcs-notice"
|
||||
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/wcs-notice.png' ); ?>"
|
||||
/>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<img
|
||||
class="jetpack-logo"
|
||||
src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_vertical_logo.png' ); ?>"
|
||||
alt="Jetpack logo"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $has_jetpack_error ) : ?>
|
||||
<p class="wc-setup-actions step">
|
||||
<a
|
||||
|
@ -1762,53 +1817,55 @@ class WC_Admin_Setup_Wizard {
|
|||
</p>
|
||||
<form method="post" class="activate-jetpack">
|
||||
<p class="wc-setup-actions step">
|
||||
<button type="submit" class="button-primary button button-large" value="<?php esc_attr_e( 'Connect with Jetpack', 'woocommerce' ); ?>"><?php esc_html_e( 'Continue with Jetpack', 'woocommerce' ); ?></button>
|
||||
<button type="submit" class="button-primary button button-large" value="<?php echo esc_attr( $button_text ); ?>"><?php echo esc_html( $button_text ); ?></button>
|
||||
</p>
|
||||
<input type="hidden" name="save_step" value="activate" />
|
||||
<?php wp_nonce_field( 'wc-setup' ); ?>
|
||||
</form>
|
||||
<h3 class="jetpack-reasons">
|
||||
<?php
|
||||
echo esc_html( $description ?
|
||||
__( "Bonus reasons you'll love Jetpack", 'woocommerce' ) :
|
||||
__( "Reasons you'll love Jetpack", 'woocommerce' )
|
||||
);
|
||||
?>
|
||||
</h3>
|
||||
<ul class="wc-wizard-features">
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Better security', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( 'Protect your store from unauthorized access.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Store stats', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( 'Get insights on how your store is doing, including total sales, top products, and more.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Store monitoring', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( 'Get an alert if your store is down for even a few minutes.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Product promotion', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( "Share new items on social media the moment they're live in your store.", 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<?php if ( ! $jetpack_connected ) : ?>
|
||||
<h3 class="jetpack-reasons">
|
||||
<?php
|
||||
echo esc_html( $description ?
|
||||
__( "Bonus reasons you'll love Jetpack", 'woocommerce' ) :
|
||||
__( "Reasons you'll love Jetpack", 'woocommerce' )
|
||||
);
|
||||
?>
|
||||
</h3>
|
||||
<ul class="wc-wizard-features">
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Better security', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( 'Protect your store from unauthorized access.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Store stats', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( 'Get insights on how your store is doing, including total sales, top products, and more.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Store monitoring', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( 'Get an alert if your store is down for even a few minutes.', 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
<li class="wc-wizard-feature-item">
|
||||
<p class="wc-wizard-feature-name">
|
||||
<strong><?php esc_html_e( 'Product promotion', 'woocommerce' ); ?></strong>
|
||||
</p>
|
||||
<p class="wc-wizard-feature-description">
|
||||
<?php esc_html_e( "Share new items on social media the moment they're live in your store.", 'woocommerce' ); ?>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
|
@ -1835,9 +1892,16 @@ class WC_Admin_Setup_Wizard {
|
|||
public function wc_setup_activate_save() {
|
||||
check_admin_referer( 'wc-setup' );
|
||||
|
||||
set_transient( 'wc_setup_activated', 'yes', MINUTE_IN_SECONDS * 10 );
|
||||
|
||||
// Leave a note for WooCommerce Services that Jetpack has been opted into.
|
||||
update_option( 'woocommerce_setup_jetpack_opted_in', true );
|
||||
|
||||
if ( class_exists( 'Jetpack' ) && Jetpack::is_active() ) {
|
||||
wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
WC_Install::background_installer( 'jetpack', array(
|
||||
'file' => 'jetpack/jetpack.php',
|
||||
'name' => __( 'Jetpack', 'woocommerce' ),
|
||||
|
|
|
@ -257,7 +257,7 @@ class WC_Meta_Box_Coupon_Data {
|
|||
'id' => 'customer_email',
|
||||
'label' => __( 'Email restrictions', 'woocommerce' ),
|
||||
'placeholder' => __( 'No restrictions', 'woocommerce' ),
|
||||
'description' => __( 'List of allowed emails to check against the customer billing email when an order is placed. Separate email addresses with commas.', 'woocommerce' ),
|
||||
'description' => __( 'List of allowed emails to check against the customer billing email when an order is placed. Separate email addresses with commas. You can also use an asterisk (*) to match parts of an email. For example "*@gmail.com" would match all gmail addresses.', 'woocommerce' ),
|
||||
'value' => implode( ', ', (array) $coupon->get_email_restrictions() ),
|
||||
'desc_tip' => true,
|
||||
'type' => 'email',
|
||||
|
|
|
@ -360,6 +360,15 @@ class WC_Meta_Box_Order_Data {
|
|||
if ( ! isset( $field['id'] ) ) {
|
||||
$field['id'] = '_billing_' . $key;
|
||||
}
|
||||
|
||||
$field_name = 'billing_' . $key;
|
||||
|
||||
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
|
||||
$field['value'] = $order->{"get_$field_name"}( 'edit' );
|
||||
} else {
|
||||
$field['value'] = $order->get_meta( '_' . $field_name );
|
||||
}
|
||||
|
||||
switch ( $field['type'] ) {
|
||||
case 'select':
|
||||
woocommerce_wp_select( $field );
|
||||
|
@ -462,6 +471,14 @@ class WC_Meta_Box_Order_Data {
|
|||
$field['id'] = '_shipping_' . $key;
|
||||
}
|
||||
|
||||
$field_name = 'shipping_' . $key;
|
||||
|
||||
if ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
|
||||
$field['value'] = $order->{"get_$field_name"}( 'edit' );
|
||||
} else {
|
||||
$field['value'] = $order->get_meta( '_' . $field_name );
|
||||
}
|
||||
|
||||
switch ( $field['type'] ) {
|
||||
case 'select':
|
||||
woocommerce_wp_select( $field );
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
*
|
||||
* Replaces the standard excerpt box.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin/Meta Boxes
|
||||
* @version 2.1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Meta_Box_Product_Short_Description Class.
|
||||
|
@ -22,7 +18,7 @@ class WC_Meta_Box_Product_Short_Description {
|
|||
/**
|
||||
* Output the metabox.
|
||||
*
|
||||
* @param WP_Post $post
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
|
||||
|
@ -36,6 +32,6 @@ class WC_Meta_Box_Product_Short_Description {
|
|||
'editor_css' => '<style>#wp-excerpt-editor-container .wp-editor-area{height:175px; width:100%;}</style>',
|
||||
);
|
||||
|
||||
wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
|
||||
wp_editor( htmlspecialchars_decode( $post->post_excerpt, ENT_QUOTES ), 'excerpt', apply_filters( 'woocommerce_product_short_description_editor_settings', $settings ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
|
|||
$r['value'] = 'id';
|
||||
$r['selected'] = $this->show_categories;
|
||||
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-dropdown-walker.php';
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';
|
||||
|
||||
echo wc_walk_category_dropdown_tree( $categories, 0, $r ); // @codingStandardsIgnoreLine
|
||||
?>
|
||||
|
|
|
@ -1,394 +1,393 @@
|
|||
<?php
|
||||
<?php // @codingStandardsIgnoreLine.
|
||||
/**
|
||||
* WooCommerce Shipping Settings
|
||||
* WooCommerce Checkout Settings
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Admin
|
||||
* @package WooCommerce/Admin
|
||||
* @version 2.5.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WC_Settings_Payment_Gateways', false ) ) {
|
||||
return new WC_Settings_Payment_Gateways();
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Settings_Payment_Gateways', false ) ) :
|
||||
/**
|
||||
* WC_Settings_Payment_Gateways.
|
||||
*/
|
||||
class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
||||
|
||||
/**
|
||||
* WC_Settings_Payment_Gateways.
|
||||
* Constructor.
|
||||
*/
|
||||
class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
||||
public function __construct() {
|
||||
$this->id = 'checkout';
|
||||
$this->label = _x( 'Checkout', 'Settings tab label', 'woocommerce' );
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'checkout';
|
||||
$this->label = _x( 'Checkout', 'Settings tab label', 'woocommerce' );
|
||||
add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) );
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
add_action( 'woocommerce_admin_field_payment_gateways', array( $this, 'payment_gateways_setting' ) );
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Get sections.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_sections() {
|
||||
$sections = array(
|
||||
'' => __( 'Checkout options', 'woocommerce' ),
|
||||
);
|
||||
|
||||
/**
|
||||
* Get sections.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_sections() {
|
||||
$sections = array(
|
||||
'' => __( 'Checkout options', 'woocommerce' ),
|
||||
);
|
||||
|
||||
if ( ! defined( 'WC_INSTALLING' ) ) {
|
||||
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
||||
|
||||
foreach ( $payment_gateways as $gateway ) {
|
||||
$title = empty( $gateway->method_title ) ? ucfirst( $gateway->id ) : $gateway->method_title;
|
||||
$sections[ strtolower( $gateway->id ) ] = esc_html( $title );
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings array.
|
||||
*
|
||||
* @param string $current_section
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_settings( $current_section = '' ) {
|
||||
$settings = array();
|
||||
|
||||
if ( '' === $current_section ) {
|
||||
$settings = apply_filters(
|
||||
'woocommerce_payment_gateways_settings', array(
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout process', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'id' => 'checkout_process_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Coupons', 'woocommerce' ),
|
||||
'desc' => __( 'Enable the use of coupons', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_coupons',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
|
||||
'id' => 'woocommerce_calc_discounts_sequentially',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ),
|
||||
'checkboxgroup' => 'end',
|
||||
'autoload' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout process', 'woocommerce' ),
|
||||
'desc' => __( 'Enable guest checkout', 'woocommerce' ),
|
||||
'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_guest_checkout',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'autoload' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'desc' => __( 'Force secure checkout', 'woocommerce' ),
|
||||
'id' => 'woocommerce_force_ssl_checkout',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
'show_if_checked' => 'option',
|
||||
'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (<a href="%s" target="_blank">an SSL Certificate is required</a>).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ),
|
||||
),
|
||||
|
||||
'unforce_ssl_checkout' => array(
|
||||
'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ),
|
||||
'id' => 'woocommerce_unforce_ssl_checkout',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
'show_if_checked' => 'yes',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'checkout_process_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout pages', 'woocommerce' ),
|
||||
'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'id' => 'checkout_page_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Cart page', 'woocommerce' ),
|
||||
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ),
|
||||
'id' => 'woocommerce_cart_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
'css' => 'min-width:300px;',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout page', 'woocommerce' ),
|
||||
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ),
|
||||
'id' => 'woocommerce_checkout_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
'css' => 'min-width:300px;',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Terms and conditions', 'woocommerce' ),
|
||||
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_terms_page_id',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
'css' => 'min-width:300px;',
|
||||
'type' => 'single_select_page',
|
||||
'args' => array( 'exclude' => wc_get_page_id( 'checkout' ) ),
|
||||
'desc_tip' => true,
|
||||
'autoload' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'checkout_page_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout endpoints', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ),
|
||||
'id' => 'account_endpoint_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pay', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the "Checkout → Pay" page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_checkout_pay_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'order-pay',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Order received', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the "Checkout → Order received" page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_checkout_order_received_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'order-received',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Add payment method', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the "Checkout → Add payment method" page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_add_payment_method_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'add-payment-method',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Delete payment method', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_delete_payment_method_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'delete-payment-method',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Set default payment method', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'set-default-payment-method',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'checkout_endpoint_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Payment gateways', 'woocommerce' ),
|
||||
'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'id' => 'payment_gateways_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'payment_gateways',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'payment_gateways_options',
|
||||
),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
if ( wc_site_is_https() ) {
|
||||
unset( $settings['unforce_ssl_checkout'] );
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the settings.
|
||||
*/
|
||||
public function output() {
|
||||
global $current_section;
|
||||
|
||||
// Load shipping methods so we can show any global options they may have.
|
||||
if ( ! defined( 'WC_INSTALLING' ) ) {
|
||||
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
||||
|
||||
if ( $current_section ) {
|
||||
foreach ( $payment_gateways as $gateway ) {
|
||||
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ) ) ) {
|
||||
$gateway->admin_options();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$settings = $this->get_settings();
|
||||
|
||||
WC_Admin_Settings::output_fields( $settings );
|
||||
foreach ( $payment_gateways as $gateway ) {
|
||||
$title = empty( $gateway->method_title ) ? ucfirst( $gateway->id ) : $gateway->method_title;
|
||||
$sections[ strtolower( $gateway->id ) ] = esc_html( $title );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output payment gateway settings.
|
||||
*/
|
||||
public function payment_gateways_setting() {
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc"><?php _e( 'Gateway display order', 'woocommerce' ); ?></th>
|
||||
<td class="forminp">
|
||||
<table class="wc_gateways widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
$columns = apply_filters(
|
||||
'woocommerce_payment_gateways_setting_columns', array(
|
||||
'sort' => '',
|
||||
'name' => __( 'Gateway', 'woocommerce' ),
|
||||
'id' => __( 'Gateway ID', 'woocommerce' ),
|
||||
'status' => __( 'Enabled', 'woocommerce' ),
|
||||
)
|
||||
);
|
||||
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
||||
}
|
||||
|
||||
foreach ( $columns as $key => $column ) {
|
||||
echo '<th class="' . esc_attr( $key ) . '">' . esc_html( $column ) . '</th>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( WC()->payment_gateways->payment_gateways() as $gateway ) {
|
||||
/**
|
||||
* Get settings array.
|
||||
*
|
||||
* @param string $current_section Section being shown.
|
||||
* @return array
|
||||
*/
|
||||
public function get_settings( $current_section = '' ) {
|
||||
$settings = array();
|
||||
|
||||
echo '<tr>';
|
||||
if ( '' === $current_section ) {
|
||||
$settings = apply_filters(
|
||||
'woocommerce_payment_gateways_settings', array(
|
||||
|
||||
foreach ( $columns as $key => $column ) {
|
||||
array(
|
||||
'title' => __( 'Checkout process', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'id' => 'checkout_process_options',
|
||||
),
|
||||
|
||||
switch ( $key ) {
|
||||
array(
|
||||
'title' => __( 'Coupons', 'woocommerce' ),
|
||||
'desc' => __( 'Enable the use of coupons', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_coupons',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'desc_tip' => __( 'Coupons can be applied from the cart and checkout pages.', 'woocommerce' ),
|
||||
),
|
||||
|
||||
case 'sort':
|
||||
echo '<td width="1%" class="sort">
|
||||
<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />
|
||||
</td>';
|
||||
break;
|
||||
array(
|
||||
'desc' => __( 'Calculate coupon discounts sequentially', 'woocommerce' ),
|
||||
'id' => 'woocommerce_calc_discounts_sequentially',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'desc_tip' => __( 'When applying multiple coupons, apply the first coupon to the full price and the second coupon to the discounted price and so on.', 'woocommerce' ),
|
||||
'checkboxgroup' => 'end',
|
||||
'autoload' => false,
|
||||
),
|
||||
|
||||
case 'name':
|
||||
$method_title = $gateway->get_title() ? $gateway->get_title() : __( '(no title)', 'woocommerce' );
|
||||
echo '<td class="name">
|
||||
<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . strtolower( $gateway->id ) ) . '">' . esc_html( $method_title ) . '</a>
|
||||
</td>';
|
||||
break;
|
||||
array(
|
||||
'title' => __( 'Checkout process', 'woocommerce' ),
|
||||
'desc' => __( 'Enable guest checkout', 'woocommerce' ),
|
||||
'desc_tip' => __( 'Allows customers to checkout without creating an account.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_enable_guest_checkout',
|
||||
'default' => 'yes',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
'autoload' => false,
|
||||
),
|
||||
|
||||
case 'id':
|
||||
echo '<td class="id">' . esc_html( $gateway->id ) . '</td>';
|
||||
break;
|
||||
array(
|
||||
'desc' => __( 'Force secure checkout', 'woocommerce' ),
|
||||
'id' => 'woocommerce_force_ssl_checkout',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => '',
|
||||
'show_if_checked' => 'option',
|
||||
/* Translators: %s Docs URL. */
|
||||
'desc_tip' => sprintf( __( 'Force SSL (HTTPS) on the checkout pages (<a href="%s" target="_blank">an SSL Certificate is required</a>).', 'woocommerce' ), 'https://docs.woocommerce.com/document/ssl-and-https/#section-3' ),
|
||||
),
|
||||
|
||||
case 'status':
|
||||
echo '<td class="status">';
|
||||
echo ( 'yes' === $gateway->enabled ) ? '<span class="status-enabled tips" data-tip="' . esc_attr__( 'Yes', 'woocommerce' ) . '">' . esc_html__( 'Yes', 'woocommerce' ) . '</span>' : '-';
|
||||
echo '</td>';
|
||||
break;
|
||||
'unforce_ssl_checkout' => array(
|
||||
'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ),
|
||||
'id' => 'woocommerce_unforce_ssl_checkout',
|
||||
'default' => 'no',
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'end',
|
||||
'show_if_checked' => 'yes',
|
||||
),
|
||||
|
||||
default:
|
||||
do_action( 'woocommerce_payment_gateways_setting_column_' . $key, $gateway );
|
||||
break;
|
||||
}
|
||||
}
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'checkout_process_options',
|
||||
),
|
||||
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
array(
|
||||
'title' => __( 'Checkout pages', 'woocommerce' ),
|
||||
'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to checkout.', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'id' => 'checkout_page_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Cart page', 'woocommerce' ),
|
||||
/* Translators: %s Page contents. */
|
||||
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' ) ),
|
||||
'id' => 'woocommerce_cart_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
'css' => 'min-width:300px;',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout page', 'woocommerce' ),
|
||||
/* Translators: %s Page contents. */
|
||||
'desc' => sprintf( __( 'Page contents: [%s]', 'woocommerce' ), apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' ) ),
|
||||
'id' => 'woocommerce_checkout_page_id',
|
||||
'type' => 'single_select_page',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
'css' => 'min-width:300px;',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Terms and conditions', 'woocommerce' ),
|
||||
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_terms_page_id',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
'css' => 'min-width:300px;',
|
||||
'type' => 'single_select_page',
|
||||
'args' => array( 'exclude' => wc_get_page_id( 'checkout' ) ),
|
||||
'desc_tip' => true,
|
||||
'autoload' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'checkout_page_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Checkout endpoints', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions during the checkout process. They should be unique.', 'woocommerce' ),
|
||||
'id' => 'account_endpoint_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Pay', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the "Checkout → Pay" page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_checkout_pay_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'order-pay',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Order received', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the "Checkout → Order received" page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_checkout_order_received_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'order-received',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Add payment method', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the "Checkout → Add payment method" page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_add_payment_method_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'add-payment-method',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Delete payment method', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the delete payment method page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_delete_payment_method_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'delete-payment-method',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Set default payment method', 'woocommerce' ),
|
||||
'desc' => __( 'Endpoint for the setting a default payment method page.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_myaccount_set_default_payment_method_endpoint',
|
||||
'type' => 'text',
|
||||
'default' => 'set-default-payment-method',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'checkout_endpoint_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Payment gateways', 'woocommerce' ),
|
||||
'desc' => __( 'Installed gateways are listed below. Drag and drop gateways to control their display order on the frontend.', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'id' => 'payment_gateways_options',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'payment_gateways',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'sectionend',
|
||||
'id' => 'payment_gateways_options',
|
||||
),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
if ( wc_site_is_https() ) {
|
||||
unset( $settings['unforce_ssl_checkout'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings.
|
||||
*/
|
||||
public function save() {
|
||||
global $current_section;
|
||||
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
||||
}
|
||||
|
||||
$wc_payment_gateways = WC_Payment_Gateways::instance();
|
||||
/**
|
||||
* Output the settings.
|
||||
*/
|
||||
public function output() {
|
||||
global $current_section;
|
||||
|
||||
if ( ! $current_section ) {
|
||||
// Prevent the T&Cs and checkout page from being set to the same page.
|
||||
if ( isset( $_POST['woocommerce_terms_page_id'], $_POST['woocommerce_checkout_page_id'] ) && $_POST['woocommerce_terms_page_id'] === $_POST['woocommerce_checkout_page_id'] ) {
|
||||
$_POST['woocommerce_terms_page_id'] = '';
|
||||
}
|
||||
// Load gateways so we can show any global options they may have.
|
||||
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
||||
|
||||
WC_Admin_Settings::save_fields( $this->get_settings() );
|
||||
$wc_payment_gateways->process_admin_options();
|
||||
|
||||
} else {
|
||||
foreach ( $wc_payment_gateways->payment_gateways() as $gateway ) {
|
||||
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ) ) ) {
|
||||
do_action( 'woocommerce_update_options_payment_gateways_' . $gateway->id );
|
||||
$wc_payment_gateways->init();
|
||||
}
|
||||
if ( $current_section ) {
|
||||
foreach ( $payment_gateways as $gateway ) {
|
||||
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ), true ) ) {
|
||||
$gateway->admin_options();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$settings = $this->get_settings();
|
||||
|
||||
if ( $current_section ) {
|
||||
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
|
||||
}
|
||||
WC_Admin_Settings::output_fields( $settings );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
/**
|
||||
* Output payment gateway settings.
|
||||
*/
|
||||
public function payment_gateways_setting() {
|
||||
?>
|
||||
<tr valign="top">
|
||||
<th scope="row" class="titledesc"><?php esc_html_e( 'Gateway display order', 'woocommerce' ); ?></th>
|
||||
<td class="forminp">
|
||||
<table class="wc_gateways widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
$columns = apply_filters(
|
||||
'woocommerce_payment_gateways_setting_columns', array(
|
||||
'sort' => '',
|
||||
'name' => __( 'Gateway', 'woocommerce' ),
|
||||
'id' => __( 'Gateway ID', 'woocommerce' ),
|
||||
'status' => __( 'Enabled', 'woocommerce' ),
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $columns as $key => $column ) {
|
||||
echo '<th class="' . esc_attr( $key ) . '">' . esc_html( $column ) . '</th>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ( WC()->payment_gateways->payment_gateways() as $gateway ) {
|
||||
|
||||
echo '<tr>';
|
||||
|
||||
foreach ( $columns as $key => $column ) {
|
||||
|
||||
switch ( $key ) {
|
||||
|
||||
case 'sort':
|
||||
echo '<td width="1%" class="sort">
|
||||
<input type="hidden" name="gateway_order[]" value="' . esc_attr( $gateway->id ) . '" />
|
||||
</td>';
|
||||
break;
|
||||
|
||||
case 'name':
|
||||
$method_title = $gateway->get_title() ? $gateway->get_title() : __( '(no title)', 'woocommerce' );
|
||||
echo '<td class="name">
|
||||
<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=' . strtolower( $gateway->id ) ) ) . '">' . esc_html( $method_title ) . '</a>
|
||||
</td>';
|
||||
break;
|
||||
|
||||
case 'id':
|
||||
echo '<td class="id">' . esc_html( $gateway->id ) . '</td>';
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
echo '<td class="status">';
|
||||
echo ( 'yes' === $gateway->enabled ) ? '<span class="status-enabled tips" data-tip="' . esc_attr__( 'Yes', 'woocommerce' ) . '">' . esc_html__( 'Yes', 'woocommerce' ) . '</span>' : '-';
|
||||
echo '</td>';
|
||||
break;
|
||||
|
||||
default:
|
||||
do_action( 'woocommerce_payment_gateways_setting_column_' . $key, $gateway );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings.
|
||||
*/
|
||||
public function save() {
|
||||
global $current_section;
|
||||
|
||||
$wc_payment_gateways = WC_Payment_Gateways::instance();
|
||||
|
||||
if ( ! $current_section ) {
|
||||
// Prevent the T&Cs and checkout page from being set to the same page.
|
||||
if ( isset( $_POST['woocommerce_terms_page_id'], $_POST['woocommerce_checkout_page_id'] ) && $_POST['woocommerce_terms_page_id'] === $_POST['woocommerce_checkout_page_id'] ) { // WPCS: input var ok, CSRF ok.
|
||||
$_POST['woocommerce_terms_page_id'] = '';
|
||||
}
|
||||
|
||||
WC_Admin_Settings::save_fields( $this->get_settings() );
|
||||
$wc_payment_gateways->process_admin_options();
|
||||
$wc_payment_gateways->init();
|
||||
|
||||
} else {
|
||||
foreach ( $wc_payment_gateways->payment_gateways() as $gateway ) {
|
||||
if ( in_array( $current_section, array( $gateway->id, sanitize_title( get_class( $gateway ) ) ), true ) ) {
|
||||
do_action( 'woocommerce_update_options_payment_gateways_' . $gateway->id );
|
||||
$wc_payment_gateways->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $current_section ) {
|
||||
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new WC_Settings_Payment_Gateways();
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin View: Notice - Tracking
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="message" class="updated woocommerce-message woocommerce-tracker">
|
||||
<p><?php printf( __( 'Want to help make WooCommerce even more awesome? Allow WooCommerce to collect non-sensitive diagnostic data and usage information, and get %1$s discount on your next WooThemes purchase. <a href="%2$s" target="_blank">Find out more</a>.', 'woocommerce' ), '20%', 'https://woocommerce.com/usage-tracking/' ); ?></p>
|
||||
<p class="submit">
|
||||
<a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc_tracker_optin', 'true' ), 'wc_tracker_optin', 'wc_tracker_nonce' ) ); ?>"><?php _e( 'Allow', 'woocommerce' ); ?></a>
|
||||
<a class="skip button-secondary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wc-hide-notice', 'tracking' ), 'woocommerce_hide_notices_nonce', '_wc_notice_nonce' ) ); ?>"><?php _e( 'No, do not bother me again', 'woocommerce' ); ?></a>
|
||||
</p>
|
||||
</div>
|
|
@ -214,6 +214,7 @@ function woocommerce_wp_select( $field ) {
|
|||
$field_attributes['style'] = $field['style'];
|
||||
$field_attributes['id'] = $field['id'];
|
||||
$field_attributes['name'] = $field['name'];
|
||||
$field_attributes['class'] = $field['class'];
|
||||
|
||||
$tooltip = ! empty( $field['description'] ) && false !== $field['desc_tip'] ? $field['description'] : '';
|
||||
$description = ! empty( $field['description'] ) && false === $field['desc_tip'] ? $field['description'] : '';
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
*
|
||||
* Handles WC-API endpoint requests.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category API
|
||||
* @package WooCommerce/API
|
||||
* @since 2.0
|
||||
* @package WooCommerce/API
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* API class.
|
||||
|
@ -130,78 +126,78 @@ class WC_API extends WC_Legacy_API {
|
|||
*/
|
||||
private function rest_api_includes() {
|
||||
// Exception handler.
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-exception.php' );
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-exception.php';
|
||||
|
||||
// Authentication.
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-authentication.php' );
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-authentication.php';
|
||||
|
||||
// Abstract controllers.
|
||||
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-posts-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-crud-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php' );
|
||||
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-posts-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-crud-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-terms-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-rest-shipping-zones-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/abstracts/abstract-wc-settings-api.php';
|
||||
|
||||
// REST API v1 controllers.
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-coupons-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-customer-downloads-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-customers-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-orders-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-notes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-refunds-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attribute-terms-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attributes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-categories-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-reviews-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-shipping-classes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-tags-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-products-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-sales-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-top-sellers-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-reports-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-tax-classes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-taxes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhook-deliveries-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhooks-controller.php' );
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-coupons-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-customer-downloads-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-customers-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-orders-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-notes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-order-refunds-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attribute-terms-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-attributes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-categories-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-reviews-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-shipping-classes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-product-tags-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-products-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-sales-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-report-top-sellers-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-reports-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-tax-classes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-taxes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhook-deliveries-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/v1/class-wc-rest-webhooks-controller.php';
|
||||
|
||||
// Legacy v2 code.
|
||||
include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-coupons-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-orders-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-products-controller.php' );
|
||||
include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-coupons-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-orders-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/legacy/class-wc-rest-legacy-products-controller.php';
|
||||
|
||||
// REST API v2 controllers.
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-customers-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-orders-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-network-orders-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-order-notes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-order-refunds-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-attribute-terms-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-attributes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-categories-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-reviews-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-shipping-classes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-tags-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-products-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-product-variations-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-report-sales-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-report-top-sellers-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-reports-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-settings-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-setting-options-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zones-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-locations-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-methods-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-tax-classes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-taxes-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhook-deliveries-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-webhooks-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-system-status-tools-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-shipping-methods-controller.php' );
|
||||
include_once( dirname( __FILE__ ) . '/api/class-wc-rest-payment-gateways-controller.php' );
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-coupons-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-customer-downloads-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-customers-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-orders-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-network-orders-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-order-notes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-order-refunds-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-attribute-terms-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-attributes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-categories-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-reviews-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-shipping-classes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-tags-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-products-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-product-variations-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-report-sales-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-report-top-sellers-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-reports-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-settings-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-setting-options-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zones-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-locations-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-zone-methods-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-tax-classes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-taxes-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-webhook-deliveries-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-webhooks-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-system-status-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-system-status-tools-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-shipping-methods-controller.php';
|
||||
include_once dirname( __FILE__ ) . '/api/class-wc-rest-payment-gateways-controller.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* WooCommerce Autoloader.
|
||||
*
|
||||
* @class WC_Autoloader
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/Classes
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Classes
|
||||
* @version 2.3.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Autoloader class.
|
||||
*/
|
||||
class WC_Autoloader {
|
||||
|
||||
|
@ -25,8 +24,8 @@ class WC_Autoloader {
|
|||
* The Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
if ( function_exists( "__autoload" ) ) {
|
||||
spl_autoload_register( "__autoload" );
|
||||
if ( function_exists( '__autoload' ) ) {
|
||||
spl_autoload_register( '__autoload' );
|
||||
}
|
||||
|
||||
spl_autoload_register( array( $this, 'autoload' ) );
|
||||
|
@ -37,7 +36,7 @@ class WC_Autoloader {
|
|||
/**
|
||||
* Take a class name and turn it into a file name.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $class Class name.
|
||||
* @return string
|
||||
*/
|
||||
private function get_file_name_from_class( $class ) {
|
||||
|
@ -47,12 +46,12 @@ class WC_Autoloader {
|
|||
/**
|
||||
* Include a class file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool successful or not
|
||||
* @param string $path File path.
|
||||
* @return bool Successful or not.
|
||||
*/
|
||||
private function load_file( $path ) {
|
||||
if ( $path && is_readable( $path ) ) {
|
||||
include_once( $path );
|
||||
include_once $path;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -61,7 +60,7 @@ class WC_Autoloader {
|
|||
/**
|
||||
* Auto-load WC classes on demand to reduce memory consumption.
|
||||
*
|
||||
* @param string $class
|
||||
* @param string $class Class name.
|
||||
*/
|
||||
public function autoload( $class ) {
|
||||
$class = strtolower( $class );
|
||||
|
@ -70,14 +69,14 @@ class WC_Autoloader {
|
|||
return;
|
||||
}
|
||||
|
||||
$file = $this->get_file_name_from_class( $class );
|
||||
$path = '';
|
||||
$file = $this->get_file_name_from_class( $class );
|
||||
$path = '';
|
||||
|
||||
if ( 0 === strpos( $class, 'wc_addons_gateway_' ) ) {
|
||||
if ( 0 === strpos( $class, 'wc_addons_gateway_' ) ) {
|
||||
$path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 18 ) . '/';
|
||||
} elseif ( 0 === strpos( $class, 'wc_gateway_' ) ) {
|
||||
} elseif ( 0 === strpos( $class, 'wc_gateway_' ) ) {
|
||||
$path = $this->include_path . 'gateways/' . substr( str_replace( '_', '-', $class ), 11 ) . '/';
|
||||
} elseif ( 0 === strpos( $class, 'wc_shipping_' ) ) {
|
||||
} elseif ( 0 === strpos( $class, 'wc_shipping_' ) ) {
|
||||
$path = $this->include_path . 'shipping/' . substr( str_replace( '_', '-', $class ), 12 ) . '/';
|
||||
} elseif ( 0 === strpos( $class, 'wc_shortcode_' ) ) {
|
||||
$path = $this->include_path . 'shortcodes/';
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
/**
|
||||
* Background Emailer
|
||||
*
|
||||
* @version 3.0.1
|
||||
* @package WooCommerce/Classes
|
||||
* @version 3.0.1
|
||||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'WC_Background_Process', false ) ) {
|
||||
include_once dirname( __FILE__ ) . '/abstracts/class-wc-background-process.php';
|
||||
|
@ -59,7 +57,7 @@ class WC_Background_Emailer extends WC_Background_Process {
|
|||
WC_Emails::send_queued_transactional_email( $callback['filter'], $callback['args'] );
|
||||
} catch ( Exception $e ) {
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING );
|
||||
trigger_error( 'Transactional email triggered fatal error for callback ' . esc_html( $callback['filter'] ), E_USER_WARNING ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +87,7 @@ class WC_Background_Emailer extends WC_Background_Process {
|
|||
if ( ! headers_sent() ) {
|
||||
header( 'Connection: close' );
|
||||
}
|
||||
@ob_end_flush();
|
||||
@ob_end_flush(); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +115,7 @@ class WC_Background_Emailer extends WC_Background_Process {
|
|||
// Pass cookies through with the request so nonces function.
|
||||
$cookies = array();
|
||||
|
||||
foreach ( $_COOKIE as $name => $value ) {
|
||||
foreach ( $_COOKIE as $name => $value ) { // WPCS: input var ok.
|
||||
if ( 'PHPSESSID' === $name ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
/**
|
||||
* Background Updater
|
||||
*
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Classes
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Classes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'WC_Background_Process', false ) ) {
|
||||
include_once dirname( __FILE__ ) . '/abstracts/class-wc-background-process.php';
|
||||
|
|
|
@ -379,6 +379,9 @@ final class WC_Cart_Totals {
|
|||
$coupon->sort = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// Allow plugins to override the default order.
|
||||
$coupon->sort = apply_filters( 'woocommerce_coupon_sort', $coupon->sort, $coupon );
|
||||
}
|
||||
|
||||
uasort( $this->coupons, array( $this, 'sort_coupons_callback' ) );
|
||||
|
@ -453,7 +456,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 = $item->price - array_sum( $taxes ) + array_sum( $new_taxes );
|
||||
$item->price = round( $item->price - array_sum( $taxes ) + array_sum( $new_taxes ) );
|
||||
}
|
||||
}
|
||||
return $item;
|
||||
|
|
|
@ -1453,7 +1453,7 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
// Limit to defined email addresses.
|
||||
$restrictions = $coupon->get_email_restrictions();
|
||||
|
||||
if ( is_array( $restrictions ) && 0 < count( $restrictions ) && 0 === count( array_intersect( $check_emails, $restrictions ) ) ) {
|
||||
if ( is_array( $restrictions ) && 0 < count( $restrictions ) && ! $this->is_coupon_emails_allowed( $check_emails, $restrictions ) ) {
|
||||
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_NOT_YOURS_REMOVED );
|
||||
$this->remove_coupon( $code );
|
||||
}
|
||||
|
@ -1500,6 +1500,37 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given email address(es) matches the ones specified on the coupon.
|
||||
*
|
||||
* @param array $check_emails Array of customer email addresses.
|
||||
* @param array $restrictions Array of allowed email addresses.
|
||||
* @return bool
|
||||
*/
|
||||
public function is_coupon_emails_allowed( $check_emails, $restrictions ) {
|
||||
|
||||
foreach ( $check_emails as $check_email ) {
|
||||
// With a direct match we return true.
|
||||
if ( in_array( $check_email, $restrictions ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Go through the allowed emails and return true if the email matches a wildcard.
|
||||
foreach ( $restrictions as $restriction ) {
|
||||
// Convert to PHP-regex syntax.
|
||||
$regex = '/' . str_replace( '*', '(.+)?', $restriction ) . '/';
|
||||
preg_match( $regex, $check_email, $match );
|
||||
if ( ! empty( $match ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No matches, this one isn't allowed.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether or not a discount has been applied.
|
||||
*
|
||||
|
|
|
@ -220,7 +220,7 @@ class WC_Frontend_Scripts {
|
|||
'selectWoo' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/selectWoo/selectWoo.full' . $suffix . '.js' ),
|
||||
'deps' => array( 'jquery' ),
|
||||
'version' => '1.0.3',
|
||||
'version' => '1.0.4',
|
||||
),
|
||||
'wc-address-i18n' => array(
|
||||
'src' => self::get_asset_url( 'assets/js/frontend/address-i18n' . $suffix . '.js' ),
|
||||
|
|
|
@ -463,7 +463,7 @@ class WC_Install {
|
|||
}
|
||||
}
|
||||
|
||||
$woocommerce_default_category = get_option( 'default_product_cat', 0 );
|
||||
$woocommerce_default_category = (int) get_option( 'default_product_cat', 0 );
|
||||
|
||||
if ( ! $woocommerce_default_category || ! term_exists( $woocommerce_default_category, 'product_cat' ) ) {
|
||||
$default_product_cat_id = 0;
|
||||
|
@ -475,7 +475,7 @@ class WC_Install {
|
|||
} else {
|
||||
$result = wp_insert_term( _x( 'Uncategorized', 'Default category slug', 'woocommerce' ), 'product_cat', array( 'slug' => $default_product_cat_slug ) );
|
||||
|
||||
if ( ! empty( $result['term_taxonomy_id'] ) ) {
|
||||
if ( ! is_wp_error( $result ) && ! empty( $result['term_taxonomy_id'] ) ) {
|
||||
$default_product_cat_id = absint( $result['term_taxonomy_id'] );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ class WC_Shipping_Rate {
|
|||
/**
|
||||
* Set rate cost.
|
||||
*
|
||||
* @todo 4.0 Prevent negative value being set. #19293
|
||||
* @since 3.2.0
|
||||
* @param string $cost
|
||||
*/
|
||||
|
|
|
@ -152,7 +152,7 @@ class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone {
|
|||
/**
|
||||
* Get shipping methods linked to this zone.
|
||||
*
|
||||
* @param bool $enabled_only Only return enabled methods.
|
||||
* @param bool $enabled_only Only return enabled methods.
|
||||
* @param string $context Getting shipping methods for what context. Valid values, admin, json.
|
||||
* @return array of objects
|
||||
*/
|
||||
|
@ -191,7 +191,7 @@ class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone {
|
|||
$methods[ $instance_id ]->method_order = absint( $raw_method->method_order );
|
||||
$methods[ $instance_id ]->enabled = $raw_method->is_enabled ? 'yes' : 'no';
|
||||
$methods[ $instance_id ]->has_settings = $methods[ $instance_id ]->has_settings();
|
||||
$methods[ $instance_id ]->settings_html = $methods[ $instance_id ]->supports( 'instance-settings-modal' ) ? $methods[ $instance_id ]->get_admin_options_html(): false;
|
||||
$methods[ $instance_id ]->settings_html = $methods[ $instance_id ]->supports( 'instance-settings-modal' ) ? $methods[ $instance_id ]->get_admin_options_html() : false;
|
||||
$methods[ $instance_id ]->method_description = wp_kses_post( wpautop( $methods[ $instance_id ]->method_description ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* Handles storage and retrieval of shipping zones
|
||||
*
|
||||
* @package WooCommerce/Classes
|
||||
* @author Automattic
|
||||
* @version 3.3.0
|
||||
* @since 2.6.0
|
||||
*/
|
||||
|
@ -29,11 +28,11 @@ class WC_Shipping_Zones {
|
|||
$zones = array();
|
||||
|
||||
foreach ( $raw_zones as $raw_zone ) {
|
||||
$zone = new WC_Shipping_Zone( $raw_zone );
|
||||
$zones[ $zone->get_id() ] = $zone->get_data();
|
||||
$zones[ $zone->get_id() ]['zone_id'] = $zone->get_id();
|
||||
$zone = new WC_Shipping_Zone( $raw_zone );
|
||||
$zones[ $zone->get_id() ] = $zone->get_data();
|
||||
$zones[ $zone->get_id() ]['zone_id'] = $zone->get_id();
|
||||
$zones[ $zone->get_id() ]['formatted_zone_location'] = $zone->get_formatted_location();
|
||||
$zones[ $zone->get_id() ]['shipping_methods'] = $zone->get_shipping_methods();
|
||||
$zones[ $zone->get_id() ]['shipping_methods'] = $zone->get_shipping_methods( false, 'json' );
|
||||
}
|
||||
|
||||
return $zones;
|
||||
|
@ -95,7 +94,7 @@ class WC_Shipping_Zones {
|
|||
$wc_shipping = WC_Shipping::instance();
|
||||
$allowed_classes = $wc_shipping->get_shipping_method_class_names();
|
||||
|
||||
if ( ! empty( $raw_shipping_method ) && in_array( $raw_shipping_method->method_id, array_keys( $allowed_classes ) ) ) {
|
||||
if ( ! empty( $raw_shipping_method ) && in_array( $raw_shipping_method->method_id, array_keys( $allowed_classes ), true ) ) {
|
||||
$class_name = $allowed_classes[ $raw_shipping_method->method_id ];
|
||||
if ( is_object( $class_name ) ) {
|
||||
$class_name = get_class( $class_name );
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
*
|
||||
* Handles shipping and loads shipping methods via hooks.
|
||||
*
|
||||
* @class WC_Shipping
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Classes/Shipping
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
* @class WC_Shipping
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce/Classes/Shipping
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
@ -20,20 +18,38 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
*/
|
||||
class WC_Shipping {
|
||||
|
||||
/** @var bool True if shipping is enabled. */
|
||||
public $enabled = false;
|
||||
|
||||
/** @var array|null Stores methods loaded into woocommerce. */
|
||||
public $shipping_methods = null;
|
||||
|
||||
/** @var array Stores the shipping classes. */
|
||||
public $shipping_classes = array();
|
||||
|
||||
/** @var array Stores packages to ship and to get quotes for. */
|
||||
public $packages = array();
|
||||
/**
|
||||
* True if shipping is enabled.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $enabled = false;
|
||||
|
||||
/**
|
||||
* @var WC_Shipping The single instance of the class
|
||||
* Stores methods loaded into woocommerce.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $shipping_methods = null;
|
||||
|
||||
/**
|
||||
* Stores the shipping classes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $shipping_classes = array();
|
||||
|
||||
/**
|
||||
* Stores packages to ship and to get quotes for.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $packages = array();
|
||||
|
||||
/**
|
||||
* The single instance of the class
|
||||
*
|
||||
* @var WC_Shipping
|
||||
* @since 2.1
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
@ -80,10 +96,10 @@ class WC_Shipping {
|
|||
*/
|
||||
public function __get( $name ) {
|
||||
// Grab from cart for backwards compatibility with versions prior to 3.2.
|
||||
if ( 'shipping_total' === $name ){
|
||||
if ( 'shipping_total' === $name ) {
|
||||
return wc()->cart->get_shipping_total();
|
||||
}
|
||||
if ( 'shipping_taxes' === $name ){
|
||||
if ( 'shipping_taxes' === $name ) {
|
||||
return wc()->cart->get_shipping_taxes();
|
||||
}
|
||||
}
|
||||
|
@ -108,17 +124,18 @@ class WC_Shipping {
|
|||
|
||||
/**
|
||||
* Shipping methods register themselves by returning their main class name through the woocommerce_shipping_methods filter.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_shipping_method_class_names() {
|
||||
// Unique Method ID => Method Class name
|
||||
// Unique Method ID => Method Class name.
|
||||
$shipping_methods = array(
|
||||
'flat_rate' => 'WC_Shipping_Flat_Rate',
|
||||
'free_shipping' => 'WC_Shipping_Free_Shipping',
|
||||
'local_pickup' => 'WC_Shipping_Local_Pickup',
|
||||
);
|
||||
|
||||
// For backwards compatibility with 2.5.x we load any ENABLED legacy shipping methods here
|
||||
// For backwards compatibility with 2.5.x we load any ENABLED legacy shipping methods here.
|
||||
$maybe_load_legacy_methods = array( 'flat_rate', 'free_shipping', 'international_delivery', 'local_delivery', 'local_pickup' );
|
||||
|
||||
foreach ( $maybe_load_legacy_methods as $method ) {
|
||||
|
@ -135,7 +152,7 @@ class WC_Shipping {
|
|||
* Loads all shipping methods which are hooked in.
|
||||
* If a $package is passed some methods may add themselves conditionally and zones will be used.
|
||||
*
|
||||
* @param array $package
|
||||
* @param array $package Package information.
|
||||
* @return array
|
||||
*/
|
||||
public function load_shipping_methods( $package = array() ) {
|
||||
|
@ -144,7 +161,7 @@ class WC_Shipping {
|
|||
$shipping_zone = WC_Shipping_Zones::get_zone_matching_package( $package );
|
||||
$this->shipping_methods = $shipping_zone->get_shipping_methods( true );
|
||||
|
||||
// Debug output
|
||||
// Debug output.
|
||||
if ( $debug_mode && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! defined( 'WC_DOING_AJAX' ) && ! wc_has_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' ) ) {
|
||||
wc_add_notice( 'Customer matched zone "' . $shipping_zone->get_zone_name() . '"' );
|
||||
}
|
||||
|
@ -160,7 +177,7 @@ class WC_Shipping {
|
|||
// Methods can register themselves manually through this hook if necessary.
|
||||
do_action( 'woocommerce_load_shipping_methods', $package );
|
||||
|
||||
// Return loaded methods
|
||||
// Return loaded methods.
|
||||
return $this->get_shipping_methods();
|
||||
}
|
||||
|
||||
|
@ -212,36 +229,17 @@ class WC_Shipping {
|
|||
*/
|
||||
public function get_shipping_classes() {
|
||||
if ( empty( $this->shipping_classes ) ) {
|
||||
$classes = get_terms( 'product_shipping_class', array( 'hide_empty' => '0', 'orderby' => 'name' ) );
|
||||
$classes = get_terms(
|
||||
'product_shipping_class', array(
|
||||
'hide_empty' => '0',
|
||||
'orderby' => 'name',
|
||||
)
|
||||
);
|
||||
$this->shipping_classes = ! is_wp_error( $classes ) ? $classes : array();
|
||||
}
|
||||
return apply_filters( 'woocommerce_get_shipping_classes', $this->shipping_classes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default method.
|
||||
* @param array $available_methods
|
||||
* @param boolean $current_chosen_method
|
||||
* @return string
|
||||
*/
|
||||
private function get_default_method( $available_methods, $current_chosen_method = false ) {
|
||||
if ( ! empty( $available_methods ) ) {
|
||||
if ( ! empty( $current_chosen_method ) ) {
|
||||
if ( isset( $available_methods[ $current_chosen_method ] ) ) {
|
||||
return $available_methods[ $current_chosen_method ]->id;
|
||||
} else {
|
||||
foreach ( $available_methods as $method_key => $method ) {
|
||||
if ( strpos( $method->id, $current_chosen_method ) === 0 ) {
|
||||
return $method->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return current( $available_methods )->id;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate shipping for (multiple) packages of cart items.
|
||||
*
|
||||
|
@ -292,7 +290,7 @@ class WC_Shipping {
|
|||
}
|
||||
|
||||
$allowed = array_keys( WC()->countries->get_shipping_countries() );
|
||||
return in_array( $package['destination']['country'], $allowed );
|
||||
return in_array( $package['destination']['country'], $allowed, true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -338,10 +336,12 @@ class WC_Shipping {
|
|||
$package['rates'] = apply_filters( 'woocommerce_package_rates', $package['rates'], $package );
|
||||
|
||||
// Store in session to avoid recalculation.
|
||||
WC()->session->set( $session_key, array(
|
||||
'package_hash' => $package_hash,
|
||||
'rates' => $package['rates'],
|
||||
) );
|
||||
WC()->session->set(
|
||||
$session_key, array(
|
||||
'package_hash' => $package_hash,
|
||||
'rates' => $package['rates'],
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$package['rates'] = $stored_rates['rates'];
|
||||
}
|
||||
|
@ -351,6 +351,7 @@ class WC_Shipping {
|
|||
|
||||
/**
|
||||
* Get packages.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_packages() {
|
||||
|
@ -368,6 +369,8 @@ class WC_Shipping {
|
|||
}
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
*
|
||||
* @deprecated 2.6.0 Was previously used to determine sort order of methods, but this is now controlled by zones and thus unused.
|
||||
*/
|
||||
public function sort_shipping_methods() {
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
/**
|
||||
* Shortcodes
|
||||
*
|
||||
* @author Automattic
|
||||
* @category Class
|
||||
* @package WooCommerce/Classes
|
||||
* @version 3.2.0
|
||||
*/
|
||||
|
|
|
@ -264,7 +264,7 @@ class WC_Structured_Data {
|
|||
$markup['offers'] = array( apply_filters( 'woocommerce_structured_data_product_offer', $markup_offer, $product ) );
|
||||
}
|
||||
|
||||
if ( $product->get_review_count() ) {
|
||||
if ( $product->get_review_count() && 'yes' === get_option( 'woocommerce_enable_review_rating' ) ) {
|
||||
$markup['aggregateRating'] = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => $product->get_average_rating(),
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Class WC_Validation file
|
||||
*
|
||||
* @package WooCommerce\Classes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,15 +15,13 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
* @class WC_Validation
|
||||
* @version 2.4.0
|
||||
* @package WooCommerce/Classes
|
||||
* @category Class
|
||||
* @author WooThemes
|
||||
*/
|
||||
class WC_Validation {
|
||||
|
||||
/**
|
||||
* Validates an email using WordPress native is_email function.
|
||||
*
|
||||
* @param string $email Email address to validate.
|
||||
* @param string $email Email address to validate.
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_email( $email ) {
|
||||
|
@ -28,7 +31,7 @@ class WC_Validation {
|
|||
/**
|
||||
* Validates a phone number using a regular expression.
|
||||
*
|
||||
* @param string $phone Phone number to validate.
|
||||
* @param string $phone Phone number to validate.
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_phone( $phone ) {
|
||||
|
@ -42,8 +45,8 @@ class WC_Validation {
|
|||
/**
|
||||
* Checks for a valid postcode.
|
||||
*
|
||||
* @param string $postcode Postcode to validate.
|
||||
* @param string $country Country to validate the postcode for.
|
||||
* @param string $postcode Postcode to validate.
|
||||
* @param string $country Country to validate the postcode for.
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_postcode( $postcode, $country ) {
|
||||
|
@ -52,36 +55,36 @@ class WC_Validation {
|
|||
}
|
||||
|
||||
switch ( $country ) {
|
||||
case 'AT' :
|
||||
case 'AT':
|
||||
$valid = (bool) preg_match( '/^([0-9]{4})$/', $postcode );
|
||||
break;
|
||||
case 'BR' :
|
||||
case 'BR':
|
||||
$valid = (bool) preg_match( '/^([0-9]{5})([-])?([0-9]{3})$/', $postcode );
|
||||
break;
|
||||
case 'CH' :
|
||||
case 'CH':
|
||||
$valid = (bool) preg_match( '/^([0-9]{4})$/i', $postcode );
|
||||
break;
|
||||
case 'DE' :
|
||||
case 'DE':
|
||||
$valid = (bool) preg_match( '/^([0]{1}[1-9]{1}|[1-9]{1}[0-9]{1})[0-9]{3}$/', $postcode );
|
||||
break;
|
||||
case 'ES' :
|
||||
case 'FR' :
|
||||
case 'ES':
|
||||
case 'FR':
|
||||
$valid = (bool) preg_match( '/^([0-9]{5})$/i', $postcode );
|
||||
break;
|
||||
case 'GB' :
|
||||
$valid = self::is_GB_postcode( $postcode );
|
||||
case 'GB':
|
||||
$valid = self::is_gb_postcode( $postcode );
|
||||
break;
|
||||
case 'JP' :
|
||||
case 'JP':
|
||||
$valid = (bool) preg_match( '/^([0-9]{3})([-])([0-9]{4})$/', $postcode );
|
||||
break;
|
||||
case 'PT' :
|
||||
case 'PT':
|
||||
$valid = (bool) preg_match( '/^([0-9]{4})([-])([0-9]{3})$/', $postcode );
|
||||
break;
|
||||
case 'US' :
|
||||
case 'US':
|
||||
$valid = (bool) preg_match( '/^([0-9]{5})(-[0-9]{4})?$/i', $postcode );
|
||||
break;
|
||||
case 'CA' :
|
||||
// CA Postal codes cannot contain D,F,I,O,Q,U and cannot start with W or Z. https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes
|
||||
case 'CA':
|
||||
// CA Postal codes cannot contain D,F,I,O,Q,U and cannot start with W or Z. https://en.wikipedia.org/wiki/Postal_codes_in_Canada#Number_of_possible_postal_codes.
|
||||
$valid = (bool) preg_match( '/^([ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ])([\ ])?(\d[ABCEGHJKLMNPRSTVWXYZ]\d)$/i', $postcode );
|
||||
break;
|
||||
case 'PL':
|
||||
|
@ -92,7 +95,7 @@ class WC_Validation {
|
|||
$valid = (bool) preg_match( '/^([0-9]{3})(\s?)([0-9]{2})$/', $postcode );
|
||||
break;
|
||||
|
||||
default :
|
||||
default:
|
||||
$valid = true;
|
||||
break;
|
||||
}
|
||||
|
@ -103,51 +106,50 @@ class WC_Validation {
|
|||
/**
|
||||
* Check if is a GB postcode.
|
||||
*
|
||||
* @author John Gardner
|
||||
* @param string $to_check A postcode
|
||||
* @param string $to_check A postcode.
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_GB_postcode( $to_check ) {
|
||||
public static function is_gb_postcode( $to_check ) {
|
||||
|
||||
// Permitted letters depend upon their position in the postcode.
|
||||
// https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
|
||||
$alpha1 = "[abcdefghijklmnoprstuwyz]"; // Character 1
|
||||
$alpha2 = "[abcdefghklmnopqrstuvwxy]"; // Character 2
|
||||
$alpha3 = "[abcdefghjkpstuw]"; // Character 3 == ABCDEFGHJKPSTUW
|
||||
$alpha4 = "[abehmnprvwxy]"; // Character 4 == ABEHMNPRVWXY
|
||||
$alpha5 = "[abdefghjlnpqrstuwxyz]"; // Character 5 != CIKMOV
|
||||
// https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation.
|
||||
$alpha1 = '[abcdefghijklmnoprstuwyz]'; // Character 1.
|
||||
$alpha2 = '[abcdefghklmnopqrstuvwxy]'; // Character 2.
|
||||
$alpha3 = '[abcdefghjkpstuw]'; // Character 3 == ABCDEFGHJKPSTUW.
|
||||
$alpha4 = '[abehmnprvwxy]'; // Character 4 == ABEHMNPRVWXY.
|
||||
$alpha5 = '[abdefghjlnpqrstuwxyz]'; // Character 5 != CIKMOV.
|
||||
|
||||
$pcexp = array();
|
||||
|
||||
// Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
|
||||
// Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA.
|
||||
$pcexp[0] = '/^(' . $alpha1 . '{1}' . $alpha2 . '{0,1}[0-9]{1,2})([0-9]{1}' . $alpha5 . '{2})$/';
|
||||
|
||||
// Expression for postcodes: ANA NAA
|
||||
// Expression for postcodes: ANA NAA.
|
||||
$pcexp[1] = '/^(' . $alpha1 . '{1}[0-9]{1}' . $alpha3 . '{1})([0-9]{1}' . $alpha5 . '{2})$/';
|
||||
|
||||
// Expression for postcodes: AANA NAA
|
||||
// Expression for postcodes: AANA NAA.
|
||||
$pcexp[2] = '/^(' . $alpha1 . '{1}' . $alpha2 . '[0-9]{1}' . $alpha4 . ')([0-9]{1}' . $alpha5 . '{2})$/';
|
||||
|
||||
// Exception for the special postcode GIR 0AA
|
||||
// Exception for the special postcode GIR 0AA.
|
||||
$pcexp[3] = '/^(gir)(0aa)$/';
|
||||
|
||||
// Standard BFPO numbers
|
||||
// Standard BFPO numbers.
|
||||
$pcexp[4] = '/^(bfpo)([0-9]{1,4})$/';
|
||||
|
||||
// c/o BFPO numbers
|
||||
// c/o BFPO numbers.
|
||||
$pcexp[5] = '/^(bfpo)(c\/o[0-9]{1,3})$/';
|
||||
|
||||
// Load up the string to check, converting into lowercase and removing spaces
|
||||
// Load up the string to check, converting into lowercase and removing spaces.
|
||||
$postcode = strtolower( $to_check );
|
||||
$postcode = str_replace( ' ', '', $postcode );
|
||||
|
||||
// Assume we are not going to find a valid postcode
|
||||
// Assume we are not going to find a valid postcode.
|
||||
$valid = false;
|
||||
|
||||
// Check the string against the six types of postcodes
|
||||
// Check the string against the six types of postcodes.
|
||||
foreach ( $pcexp as $regexp ) {
|
||||
if ( preg_match( $regexp, $postcode, $matches ) ) {
|
||||
// Remember that we have found that the code is valid and break from loop
|
||||
// Remember that we have found that the code is valid and break from loop.
|
||||
$valid = true;
|
||||
break;
|
||||
}
|
||||
|
@ -159,16 +161,16 @@ class WC_Validation {
|
|||
/**
|
||||
* Format the postcode according to the country and length of the postcode.
|
||||
*
|
||||
* @param string $postcode Postcode to format.
|
||||
* @param string $country Country to format the postcode for.
|
||||
* @return string Formatted postcode.
|
||||
* @param string $postcode Postcode to format.
|
||||
* @param string $country Country to format the postcode for.
|
||||
* @return string Formatted postcode.
|
||||
*/
|
||||
public static function format_postcode( $postcode, $country ) {
|
||||
return wc_format_postcode( $postcode, $country );
|
||||
}
|
||||
|
||||
/**
|
||||
* format_phone function.
|
||||
* Format a given phone number.
|
||||
*
|
||||
* @param mixed $tel Phone number to format.
|
||||
* @return string
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
*
|
||||
* @version 3.2.0
|
||||
* @package WooCommerce/Webhooks
|
||||
* @category Webhooks
|
||||
* @since 2.2.0
|
||||
* @author Automattic
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
|
|
@ -700,6 +700,8 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
foreach ( $attributes as $attribute_key => $attribute ) {
|
||||
$value = '';
|
||||
|
||||
delete_transient( 'wc_layered_nav_counts_' . $attribute_key );
|
||||
|
||||
if ( is_null( $attribute ) ) {
|
||||
if ( taxonomy_exists( $attribute_key ) ) {
|
||||
// Handle attributes that have been unset.
|
||||
|
@ -725,7 +727,6 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
}
|
||||
}
|
||||
update_post_meta( $product->get_id(), '_product_attributes', $meta_values );
|
||||
delete_transient( 'wc_layered_nav_counts' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1362,7 +1363,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
|||
|
||||
foreach ( $search_terms as $search_term ) {
|
||||
$like = '%' . $wpdb->esc_like( $search_term ) . '%';
|
||||
$term_group_query .= $wpdb->prepare( " {$searchand} ( ( posts.post_title LIKE %s) OR ( posts.post_content LIKE %s ) OR ( postmeta.meta_key = '_sku' AND postmeta.meta_value LIKE %s ) )", $like, $like, $like ); // @codingStandardsIgnoreLine.
|
||||
$term_group_query .= $wpdb->prepare( " {$searchand} ( ( posts.post_title LIKE %s) OR ( posts.post_excerpt LIKE %s) OR ( posts.post_content LIKE %s ) OR ( postmeta.meta_key = '_sku' AND postmeta.meta_value LIKE %s ) )", $like, $like, $like ); // @codingStandardsIgnoreLine.
|
||||
$searchand = ' AND ';
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class WC_Product_Variable_Data_Store_CPT extends WC_Product_Data_Store_CPT imple
|
|||
);
|
||||
|
||||
// Empty value indicates that all options for given attribute are available.
|
||||
if ( in_array( '', $values, true ) || empty( $values ) ) {
|
||||
if ( in_array( null, $values, true ) || in_array( '', $values, true ) || empty( $values ) ) {
|
||||
$values = $attribute['is_taxonomy'] ? wc_get_object_terms( $product->get_id(), $attribute['name'], 'slug' ) : wc_get_text_attributes( $attribute['value'] );
|
||||
// Get custom attributes (non taxonomy) as defined.
|
||||
} elseif ( ! $attribute['is_taxonomy'] ) {
|
||||
|
|
|
@ -359,7 +359,7 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
|
|||
|
||||
if ( $order->get_total() > 0 ) {
|
||||
// Mark as on-hold (we're awaiting the payment).
|
||||
$order->update_status( 'on-hold', __( 'Awaiting BACS payment', 'woocommerce' ) );
|
||||
$order->update_status( apply_filters( 'woocommerce_bacs_process_payment_order_status', 'on-hold', $order ), __( 'Awaiting BACS payment', 'woocommerce' ) );
|
||||
} else {
|
||||
$order->payment_complete();
|
||||
}
|
||||
|
|
|
@ -317,8 +317,9 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
|
|||
*/
|
||||
protected function set_product_data( &$product, $data ) {
|
||||
if ( isset( $data['raw_attributes'] ) ) {
|
||||
$attributes = array();
|
||||
$default_attributes = array();
|
||||
$attributes = array();
|
||||
$default_attributes = array();
|
||||
$existing_attributes = $product->get_attributes();
|
||||
|
||||
foreach ( $data['raw_attributes'] as $position => $attribute ) {
|
||||
$attribute_id = 0;
|
||||
|
@ -335,12 +336,22 @@ abstract class WC_Product_Importer implements WC_Importer_Interface {
|
|||
$is_visible = 1;
|
||||
}
|
||||
|
||||
// Set if is a variation attribute.
|
||||
// Get name.
|
||||
$attribute_name = $attribute_id ? wc_attribute_taxonomy_name_by_id( $attribute_id ) : $attribute['name'];
|
||||
|
||||
// Set if is a variation attribute based on existing attributes if possible so updates via CSV do not change this.
|
||||
$is_variation = 0;
|
||||
|
||||
if ( $attribute_id ) {
|
||||
$attribute_name = wc_attribute_taxonomy_name_by_id( $attribute_id );
|
||||
if ( $existing_attributes ) {
|
||||
foreach ( $existing_attributes as $existing_attribute ) {
|
||||
if ( $existing_attribute->get_name() === $attribute_name ) {
|
||||
$is_variation = $existing_attribute->get_variation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $attribute_id ) {
|
||||
if ( isset( $attribute['value'] ) ) {
|
||||
$options = array_map( 'wc_sanitize_term_text_based', $attribute['value'] );
|
||||
$options = array_filter( $options, 'strlen' );
|
||||
|
|
|
@ -1,104 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* WC_Product_Cat_Dropdown_Walker class
|
||||
* Legacy WC_Product_Cat_Dropdown_Walker file
|
||||
*
|
||||
* @extends Walker
|
||||
* @class WC_Product_Cat_Dropdown_Walker
|
||||
* @version 1.6.4
|
||||
* @package WooCommerce/Classes/Walkers
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Classes/Walkers
|
||||
* @deprecated 3.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) :
|
||||
|
||||
class WC_Product_Cat_Dropdown_Walker extends Walker {
|
||||
|
||||
/**
|
||||
* What the class handles.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tree_type = 'category';
|
||||
|
||||
/**
|
||||
* DB fields to use.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $db_fields = array(
|
||||
'parent' => 'parent',
|
||||
'id' => 'term_id',
|
||||
'slug' => 'slug',
|
||||
);
|
||||
|
||||
/**
|
||||
* Starts the list before the elements are added.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $cat
|
||||
* @param int $depth Depth of category in reference to parents.
|
||||
* @param array $args
|
||||
* @param int $current_object_id
|
||||
*/
|
||||
public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
||||
|
||||
if ( ! empty( $args['hierarchical'] ) ) {
|
||||
$pad = str_repeat( ' ', $depth * 3 );
|
||||
} else {
|
||||
$pad = '';
|
||||
}
|
||||
|
||||
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
||||
$value = ( isset( $args['value'] ) && 'id' === $args['value'] ) ? $cat->term_id : $cat->slug;
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $value ) . "\"";
|
||||
|
||||
if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) ) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
|
||||
$output .= '>';
|
||||
$output .= esc_html( $pad . _x( $cat_name, 'product category name', 'woocommerce' ) );
|
||||
|
||||
if ( ! empty( $args['show_count'] ) ) {
|
||||
$output .= ' (' . absint( $cat->count ) . ')';
|
||||
}
|
||||
|
||||
$output .= "</option>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse elements to create list from elements.
|
||||
*
|
||||
* Display one element if the element doesn't have any children otherwise,
|
||||
* display the element and its children. Will only traverse up to the max.
|
||||
* depth and no ignore elements under that depth. It is possible to set the.
|
||||
* max depth to include all depths, see walk() method.
|
||||
*
|
||||
* This method shouldn't be called directly, use the walk() method instead.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param object $element Data object
|
||||
* @param array $children_elements List of elements to continue traversing.
|
||||
* @param int $max_depth Max depth to traverse.
|
||||
* @param int $depth Depth of current element.
|
||||
* @param array $args
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @return null Null on failure with no changes to parameters.
|
||||
*/
|
||||
public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
||||
if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
require dirname( __FILE__ ) . '/class-wc-product-cat-dropdown-walker.php';
|
||||
|
|
|
@ -1,153 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* WC_Product_Cat_List_Walker class
|
||||
* Legacy WC_Product_Cat_List_Walker file
|
||||
*
|
||||
* @extends Walker
|
||||
* @class WC_Product_Cat_Dropdown_Walker
|
||||
* @version 2.3.0
|
||||
* @package WooCommerce/Classes/Walkers
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Classes/Walkers
|
||||
* @deprecated 3.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( ! class_exists( 'WC_Product_Cat_List_Walker', false ) ) :
|
||||
|
||||
class WC_Product_Cat_List_Walker extends Walker {
|
||||
|
||||
/**
|
||||
* What the class handles.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tree_type = 'product_cat';
|
||||
|
||||
/**
|
||||
* DB fields to use.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $db_fields = array(
|
||||
'parent' => 'parent',
|
||||
'id' => 'term_id',
|
||||
'slug' => 'slug',
|
||||
);
|
||||
|
||||
/**
|
||||
* Starts the list before the elements are added.
|
||||
*
|
||||
* @see Walker::start_lvl()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of category. Used for tab indentation.
|
||||
* @param array $args Will only append content if style argument value is 'list'.
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
if ( 'list' != $args['style'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent<ul class='children'>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the list of after the elements are added.
|
||||
*
|
||||
* @see Walker::end_lvl()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of category. Used for tab indentation.
|
||||
* @param array $args Will only append content if style argument value is 'list'.
|
||||
*/
|
||||
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
if ( 'list' != $args['style'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent</ul>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the element output.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $cat
|
||||
* @param int $depth Depth of category in reference to parents.
|
||||
* @param array $args
|
||||
* @param integer $current_object_id
|
||||
*/
|
||||
public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
||||
$output .= '<li class="cat-item cat-item-' . $cat->term_id;
|
||||
|
||||
if ( $args['current_category'] == $cat->term_id ) {
|
||||
$output .= ' current-cat';
|
||||
}
|
||||
|
||||
if ( $args['has_children'] && $args['hierarchical'] && ( empty( $args['max_depth'] ) || $args['max_depth'] > $depth + 1 ) ) {
|
||||
$output .= ' cat-parent';
|
||||
}
|
||||
|
||||
if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat->term_id, $args['current_category_ancestors'] ) ) {
|
||||
$output .= ' current-cat-parent';
|
||||
}
|
||||
|
||||
$output .= '"><a href="' . get_term_link( (int) $cat->term_id, $this->tree_type ) . '">' . _x( $cat->name, 'product category name', 'woocommerce' ) . '</a>';
|
||||
|
||||
if ( $args['show_count'] ) {
|
||||
$output .= ' <span class="count">(' . $cat->count . ')</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the element output, if needed.
|
||||
*
|
||||
* @see Walker::end_el()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $cat
|
||||
* @param int $depth Depth of category. Not used.
|
||||
* @param array $args Only uses 'list' for whether should append to output.
|
||||
*/
|
||||
public function end_el( &$output, $cat, $depth = 0, $args = array() ) {
|
||||
$output .= "</li>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse elements to create list from elements.
|
||||
*
|
||||
* Display one element if the element doesn't have any children otherwise,
|
||||
* display the element and its children. Will only traverse up to the max.
|
||||
* depth and no ignore elements under that depth. It is possible to set the.
|
||||
* max depth to include all depths, see walk() method.
|
||||
*
|
||||
* This method shouldn't be called directly, use the walk() method instead.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param object $element Data object
|
||||
* @param array $children_elements List of elements to continue traversing.
|
||||
* @param int $max_depth Max depth to traverse.
|
||||
* @param int $depth Depth of current element.
|
||||
* @param array $args
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @return null Null on failure with no changes to parameters.
|
||||
*/
|
||||
public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
||||
if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
require dirname( __FILE__ ) . '/class-wc-product-cat-list-walker.php';
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
* WC_Product_Cat_Dropdown_Walker class
|
||||
*
|
||||
* @package WooCommerce/Classes/Walkers
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product category dropdown walker class.
|
||||
*/
|
||||
class WC_Product_Cat_Dropdown_Walker extends Walker {
|
||||
|
||||
/**
|
||||
* What the class handles.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tree_type = 'category';
|
||||
|
||||
/**
|
||||
* DB fields to use.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $db_fields = array(
|
||||
'parent' => 'parent',
|
||||
'id' => 'term_id',
|
||||
'slug' => 'slug',
|
||||
);
|
||||
|
||||
/**
|
||||
* Starts the list before the elements are added.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $cat Category.
|
||||
* @param int $depth Depth of category in reference to parents.
|
||||
* @param array $args Arguments.
|
||||
* @param int $current_object_id Current object ID.
|
||||
*/
|
||||
public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
||||
|
||||
if ( ! empty( $args['hierarchical'] ) ) {
|
||||
$pad = str_repeat( ' ', $depth * 3 );
|
||||
} else {
|
||||
$pad = '';
|
||||
}
|
||||
|
||||
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
||||
$value = ( isset( $args['value'] ) && 'id' === $args['value'] ) ? $cat->term_id : $cat->slug;
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $value ) . '"';
|
||||
|
||||
if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'], true ) ) ) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
|
||||
$output .= '>';
|
||||
$output .= esc_html( $pad . $cat_name );
|
||||
|
||||
if ( ! empty( $args['show_count'] ) ) {
|
||||
$output .= ' (' . absint( $cat->count ) . ')';
|
||||
}
|
||||
|
||||
$output .= "</option>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse elements to create list from elements.
|
||||
*
|
||||
* Display one element if the element doesn't have any children otherwise,
|
||||
* display the element and its children. Will only traverse up to the max.
|
||||
* depth and no ignore elements under that depth. It is possible to set the.
|
||||
* max depth to include all depths, see walk() method.
|
||||
*
|
||||
* This method shouldn't be called directly, use the walk() method instead.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param object $element Data object.
|
||||
* @param array $children_elements List of elements to continue traversing.
|
||||
* @param int $max_depth Max depth to traverse.
|
||||
* @param int $depth Depth of current element.
|
||||
* @param array $args Arguments.
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @return null Null on failure with no changes to parameters.
|
||||
*/
|
||||
public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
||||
if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
/**
|
||||
* WC_Product_Cat_List_Walker class
|
||||
*
|
||||
* @package WooCommerce/Classes/Walkers
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( class_exists( 'WC_Product_Cat_List_Walker', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Product cat list walker class.
|
||||
*/
|
||||
class WC_Product_Cat_List_Walker extends Walker {
|
||||
|
||||
/**
|
||||
* What the class handles.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tree_type = 'product_cat';
|
||||
|
||||
/**
|
||||
* DB fields to use.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $db_fields = array(
|
||||
'parent' => 'parent',
|
||||
'id' => 'term_id',
|
||||
'slug' => 'slug',
|
||||
);
|
||||
|
||||
/**
|
||||
* Starts the list before the elements are added.
|
||||
*
|
||||
* @see Walker::start_lvl()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of category. Used for tab indentation.
|
||||
* @param array $args Will only append content if style argument value is 'list'.
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
if ( 'list' !== $args['style'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent<ul class='children'>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the list of after the elements are added.
|
||||
*
|
||||
* @see Walker::end_lvl()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of category. Used for tab indentation.
|
||||
* @param array $args Will only append content if style argument value is 'list'.
|
||||
*/
|
||||
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
if ( 'list' !== $args['style'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent</ul>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the element output.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $cat Category.
|
||||
* @param int $depth Depth of category in reference to parents.
|
||||
* @param array $args Arguments.
|
||||
* @param integer $current_object_id Current object ID.
|
||||
*/
|
||||
public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
||||
$cat_id = intval( $cat->term_id );
|
||||
|
||||
$output .= '<li class="cat-item cat-item-' . $cat_id;
|
||||
|
||||
if ( $args['current_category'] === $cat_id ) {
|
||||
$output .= ' current-cat';
|
||||
}
|
||||
|
||||
if ( $args['has_children'] && $args['hierarchical'] && ( empty( $args['max_depth'] ) || $args['max_depth'] > $depth + 1 ) ) {
|
||||
$output .= ' cat-parent';
|
||||
}
|
||||
|
||||
if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat_id, $args['current_category_ancestors'], true ) ) {
|
||||
$output .= ' current-cat-parent';
|
||||
}
|
||||
|
||||
$output .= '"><a href="' . get_term_link( $cat_id, $this->tree_type ) . '">' . apply_filters( 'list_product_cats', $cat->name, $cat ) . '</a>';
|
||||
|
||||
if ( $args['show_count'] ) {
|
||||
$output .= ' <span class="count">(' . $cat->count . ')</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the element output, if needed.
|
||||
*
|
||||
* @see Walker::end_el()
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $cat Category.
|
||||
* @param int $depth Depth of category. Not used.
|
||||
* @param array $args Only uses 'list' for whether should append to output.
|
||||
*/
|
||||
public function end_el( &$output, $cat, $depth = 0, $args = array() ) {
|
||||
$output .= "</li>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse elements to create list from elements.
|
||||
*
|
||||
* Display one element if the element doesn't have any children otherwise,
|
||||
* display the element and its children. Will only traverse up to the max.
|
||||
* depth and no ignore elements under that depth. It is possible to set the.
|
||||
* max depth to include all depths, see walk() method.
|
||||
*
|
||||
* This method shouldn't be called directly, use the walk() method instead.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @param object $element Data object.
|
||||
* @param array $children_elements List of elements to continue traversing.
|
||||
* @param int $max_depth Max depth to traverse.
|
||||
* @param int $depth Depth of current element.
|
||||
* @param array $args Arguments.
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @return null Null on failure with no changes to parameters.
|
||||
*/
|
||||
public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
|
||||
if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) {
|
||||
return;
|
||||
}
|
||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||
}
|
||||
}
|
|
@ -450,7 +450,7 @@ function wc_create_attribute( $args ) {
|
|||
} elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) {
|
||||
/* translators: %s: attribute slug */
|
||||
return new WP_Error( 'invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
|
||||
} elseif ( ( 0 === $id && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) || ( isset( $args['old_slug'] ) && $args['old_slug'] !== $args['slug'] && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) ) {
|
||||
} elseif ( ( 0 === $id && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) || ( isset( $args['old_slug'] ) && $args['old_slug'] !== $slug && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) ) {
|
||||
/* translators: %s: attribute slug */
|
||||
return new WP_Error( 'invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), $slug ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
*
|
||||
* Functions for determining the current query/page.
|
||||
*
|
||||
* @author WooThemes
|
||||
* @category Core
|
||||
* @package WooCommerce/Functions
|
||||
* @version 2.3.0
|
||||
*/
|
||||
|
@ -128,7 +126,7 @@ if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
|
|||
/**
|
||||
* Is_wc_endpoint_url - Check if an endpoint is showing.
|
||||
*
|
||||
* @param string $endpoint Whether endpoint.
|
||||
* @param string|false $endpoint Whether endpoint.
|
||||
* @return bool
|
||||
*/
|
||||
function is_wc_endpoint_url( $endpoint = false ) {
|
||||
|
@ -272,7 +270,7 @@ if ( ! function_exists( 'is_filtered' ) ) {
|
|||
* @return bool
|
||||
*/
|
||||
function is_filtered() {
|
||||
return apply_filters( 'woocommerce_is_filtered', ( count( WC_Query::get_layered_nav_chosen_attributes() ) > 0 || isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) || isset( $_GET['rating_filter'] ) ) );
|
||||
return apply_filters( 'woocommerce_is_filtered', ( count( WC_Query::get_layered_nav_chosen_attributes() ) > 0 || isset( $_GET['max_price'] ) || isset( $_GET['min_price'] ) || isset( $_GET['rating_filter'] ) ) ); // WPCS: CSRF ok.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +306,7 @@ if ( ! function_exists( 'meta_is_product_attribute' ) ) {
|
|||
if ( $product && method_exists( $product, 'get_variation_attributes' ) ) {
|
||||
$variation_attributes = $product->get_variation_attributes();
|
||||
$attributes = $product->get_attributes();
|
||||
return ( in_array( $name, array_keys( $attributes ) ) && in_array( $value, $variation_attributes[ $attributes[ $name ]['name'] ] ) );
|
||||
return ( in_array( $name, array_keys( $attributes ), true ) && in_array( $value, $variation_attributes[ $attributes[ $name ]['name'] ], true ) );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -693,10 +693,19 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
|
|||
$attachment = get_post( $attachment_id );
|
||||
|
||||
if ( $attachment ) {
|
||||
$props['title'] = trim( strip_tags( $attachment->post_title ) );
|
||||
$props['caption'] = trim( strip_tags( $attachment->post_excerpt ) );
|
||||
$props['title'] = wp_strip_all_tags( $attachment->post_title );
|
||||
$props['caption'] = wp_strip_all_tags( $attachment->post_excerpt );
|
||||
$props['url'] = wp_get_attachment_url( $attachment_id );
|
||||
$props['alt'] = trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) );
|
||||
|
||||
// Alt text.
|
||||
$alt_text = array( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ), $props['caption'], wp_strip_all_tags( $attachment->post_title ) );
|
||||
|
||||
if ( $product ) {
|
||||
$alt_text[] = wp_strip_all_tags( get_the_title( $product->ID ) );
|
||||
}
|
||||
|
||||
$alt_text = array_filter( $alt_text );
|
||||
$props['alt'] = isset( $alt_text[0] ) ? $alt_text[0] : '';
|
||||
|
||||
// Large version.
|
||||
$src = wp_get_attachment_image_src( $attachment_id, 'full' );
|
||||
|
@ -704,6 +713,14 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
|
|||
$props['full_src_w'] = $src[1];
|
||||
$props['full_src_h'] = $src[2];
|
||||
|
||||
// Gallery thumbnail.
|
||||
$gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' );
|
||||
$gallery_thumbnail_size = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) );
|
||||
$src = wp_get_attachment_image_src( $attachment_id, $gallery_thumbnail_size );
|
||||
$props['gallery_thumbnail_src'] = $src[0];
|
||||
$props['gallery_thumbnail_src_w'] = $src[1];
|
||||
$props['gallery_thumbnail_src_h'] = $src[2];
|
||||
|
||||
// Thumbnail version.
|
||||
$src = wp_get_attachment_image_src( $attachment_id, 'woocommerce_thumbnail' );
|
||||
$props['thumb_src'] = $src[0];
|
||||
|
@ -717,11 +734,6 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
|
|||
$props['src_h'] = $src[2];
|
||||
$props['srcset'] = function_exists( 'wp_get_attachment_image_srcset' ) ? wp_get_attachment_image_srcset( $attachment_id, 'woocommerce_single' ) : false;
|
||||
$props['sizes'] = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $attachment_id, 'woocommerce_single' ) : false;
|
||||
|
||||
// Alt text fallbacks.
|
||||
$props['alt'] = empty( $props['alt'] ) ? $props['caption'] : $props['alt'];
|
||||
$props['alt'] = empty( $props['alt'] ) ? trim( strip_tags( $attachment->post_title ) ) : $props['alt'];
|
||||
$props['alt'] = empty( $props['alt'] ) && $product ? trim( strip_tags( get_the_title( $product->ID ) ) ) : $props['alt'];
|
||||
}
|
||||
return $props;
|
||||
}
|
||||
|
|
|
@ -982,7 +982,6 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
|
|||
if ( ! wc_get_loop_prop( 'is_paginated' ) || ! woocommerce_products_will_display() ) {
|
||||
return;
|
||||
}
|
||||
$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); // WPCS: sanitization ok, input var ok, CSRF ok.
|
||||
$show_default_orderby = 'menu_order' === apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
||||
$catalog_orderby_options = apply_filters( 'woocommerce_catalog_orderby', array(
|
||||
'menu_order' => __( 'Default sorting', 'woocommerce' ),
|
||||
|
@ -993,12 +992,13 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
|
|||
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
$default_orderby = wc_get_loop_prop( 'is_search' ) ? 'relevance' : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
|
||||
$orderby = isset( $_GET['orderby'] ) ? wc_clean( wp_unslash( $_GET['orderby'] ) ) : $default_orderby; // WPCS: sanitization ok, input var ok, CSRF ok.
|
||||
|
||||
if ( wc_get_loop_prop( 'is_search' ) ) {
|
||||
$catalog_orderby_options = array_merge( array( 'relevance' => __( 'Relevance', 'woocommerce' ) ), $catalog_orderby_options );
|
||||
|
||||
unset( $catalog_orderby_options['menu_order'] );
|
||||
if ( 'menu_order' === $orderby ) {
|
||||
$orderby = 'relevance';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $show_default_orderby ) {
|
||||
|
@ -1009,6 +1009,10 @@ if ( ! function_exists( 'woocommerce_catalog_ordering' ) ) {
|
|||
unset( $catalog_orderby_options['rating'] );
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( $orderby, $catalog_orderby_options ) ) {
|
||||
$orderby = current( array_keys( $catalog_orderby_options ) );
|
||||
}
|
||||
|
||||
wc_get_template( 'loop/orderby.php', array(
|
||||
'catalog_orderby_options' => $catalog_orderby_options,
|
||||
'orderby' => $orderby,
|
||||
|
@ -1961,8 +1965,8 @@ if ( ! function_exists( 'woocommerce_output_product_categories' ) ) {
|
|||
*/
|
||||
function woocommerce_output_product_categories( $args = array() ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'before' => apply_filters( woocommerce_before_output_product_categories, '' ),
|
||||
'after' => apply_filters( woocommerce_after_output_product_categories, '' ),
|
||||
'before' => apply_filters( 'woocommerce_before_output_product_categories', '' ),
|
||||
'after' => apply_filters( 'woocommerce_after_output_product_categories', '' ),
|
||||
'parent_id' => 0,
|
||||
) );
|
||||
|
||||
|
@ -2326,8 +2330,18 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
|||
$field = sprintf( $field_container, $container_class, $container_id, $field_html );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by type.
|
||||
*/
|
||||
$field = apply_filters( 'woocommerce_form_field_' . $args['type'], $field, $key, $args, $value );
|
||||
|
||||
/**
|
||||
* General filter on form fields.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
$field = apply_filters( 'woocommerce_form_field', $field, $key, $args, $value );
|
||||
|
||||
if ( $args['return'] ) {
|
||||
return $field;
|
||||
} else {
|
||||
|
|
|
@ -219,7 +219,7 @@ function wc_walk_category_dropdown_tree() {
|
|||
$args = func_get_args();
|
||||
|
||||
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) {
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-dropdown-walker.php';
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';
|
||||
}
|
||||
|
||||
// The user's options are the third parameter.
|
||||
|
|
|
@ -369,13 +369,22 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
|||
|
||||
// We have a query - let's see if cached results of this query already exist.
|
||||
$query_hash = md5( $query );
|
||||
$cached_counts = (array) get_transient( 'wc_layered_nav_counts' );
|
||||
|
||||
// Maybe store a transient of the count values.
|
||||
$cache = apply_filters( 'woocommerce_layered_nav_count_maybe_cache', true );
|
||||
if ( true === $cache ) {
|
||||
$cached_counts = (array) get_transient( 'wc_layered_nav_counts_' . $taxonomy );
|
||||
} else {
|
||||
$cached_counts = array();
|
||||
}
|
||||
|
||||
if ( ! isset( $cached_counts[ $query_hash ] ) ) {
|
||||
$results = $wpdb->get_results( $query, ARRAY_A ); // @codingStandardsIgnoreLine
|
||||
$counts = array_map( 'absint', wp_list_pluck( $results, 'term_count', 'term_count_id' ) );
|
||||
$cached_counts[ $query_hash ] = $counts;
|
||||
set_transient( 'wc_layered_nav_counts', $cached_counts, DAY_IN_SECONDS );
|
||||
if ( true === $cache ) {
|
||||
set_transient( 'wc_layered_nav_counts_' . $taxonomy, $cached_counts, DAY_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
return array_map( 'absint', (array) $cached_counts[ $query_hash ] );
|
||||
|
|
|
@ -250,7 +250,7 @@ class WC_Widget_Product_Categories extends WC_Widget {
|
|||
"
|
||||
);
|
||||
} else {
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php';
|
||||
include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-list-walker.php';
|
||||
|
||||
$list_args['walker'] = new WC_Product_Cat_List_Walker();
|
||||
$list_args['title_li'] = '';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "woocommerce",
|
||||
"version": "3.1.0",
|
||||
"version": "3.3.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1334,9 +1334,9 @@
|
|||
}
|
||||
},
|
||||
"chromedriver": {
|
||||
"version": "2.33.2",
|
||||
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-2.33.2.tgz",
|
||||
"integrity": "sha512-etnQeM8Mqiys50ZB4IiuNqeB1WS2/EKFhVXwkPQ1qjzKMMAJUyrLjaRUcoZoHrbjGscnhBrWkRR+p3zcTGMhDg==",
|
||||
"version": "2.36.0",
|
||||
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-2.36.0.tgz",
|
||||
"integrity": "sha512-Lq2HrigCJ4RVdIdCmchenv1rVrejNSJ7EUCQojycQo12ww3FedQx4nb+GgTdqMhjbOMTqq5+ziaiZlrEN2z1gQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"del": "3.0.0",
|
||||
|
@ -6032,9 +6032,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"url-join": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.2.tgz",
|
||||
"integrity": "sha1-wHJ1aWetJLi1nldBVRyqx49QuLc=",
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.5.tgz",
|
||||
"integrity": "sha1-WvIvGMBSoACkjXuCxenC4v7tpyg=",
|
||||
"dev": true
|
||||
},
|
||||
"user-home": {
|
||||
|
@ -6086,9 +6086,9 @@
|
|||
}
|
||||
},
|
||||
"wc-e2e-page-objects": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/wc-e2e-page-objects/-/wc-e2e-page-objects-0.5.0.tgz",
|
||||
"integrity": "sha1-7oAQnDRqn9HE4NUbi7h/oeHDcMs=",
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/wc-e2e-page-objects/-/wc-e2e-page-objects-0.9.0.tgz",
|
||||
"integrity": "sha512-oGOLFAN+lNULLylZkhNIMGT0n5hO+elpcVkpNQcT4HgWfS1yPoGfeWgrfAX33b4ZGVlpViv78Fj3LM5TciXVHw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lodash": "4.17.4",
|
||||
|
@ -6174,7 +6174,22 @@
|
|||
"selenium-webdriver": "3.6.0",
|
||||
"slugs": "0.1.3",
|
||||
"temp": "0.8.3",
|
||||
"url-join": "2.0.2"
|
||||
"url-join": "2.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"chromedriver": {
|
||||
"version": "2.33.2",
|
||||
"resolved": "https://registry.npmjs.org/chromedriver/-/chromedriver-2.33.2.tgz",
|
||||
"integrity": "sha512-etnQeM8Mqiys50ZB4IiuNqeB1WS2/EKFhVXwkPQ1qjzKMMAJUyrLjaRUcoZoHrbjGscnhBrWkRR+p3zcTGMhDg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"del": "3.0.0",
|
||||
"extract-zip": "1.6.6",
|
||||
"kew": "0.7.0",
|
||||
"mkdirp": "0.5.1",
|
||||
"request": "2.83.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"wrap-ansi": {
|
||||
|
@ -6209,13 +6224,13 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"sax": "1.2.4",
|
||||
"xmlbuilder": "9.0.4"
|
||||
"xmlbuilder": "9.0.7"
|
||||
}
|
||||
},
|
||||
"xmlbuilder": {
|
||||
"version": "9.0.4",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.4.tgz",
|
||||
"integrity": "sha1-UZy0ymhtAFqEINNJbz8MruzKWA8=",
|
||||
"version": "9.0.7",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz",
|
||||
"integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=",
|
||||
"dev": true
|
||||
},
|
||||
"xtend": {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"babel-preset-stage-2": "^6.13.0",
|
||||
"chai": "^3.5.0",
|
||||
"chai-as-promised": "^6.0.0",
|
||||
"chromedriver": "^2.33.0",
|
||||
"chromedriver": "^2.36.0",
|
||||
"config": "^1.24.0",
|
||||
"cross-env": "~5.1.1",
|
||||
"grunt": "~1.0.1",
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<exclude name="WordPress.VIP.RestrictedFunctions" />
|
||||
<exclude name="WordPress.VIP.RestrictedVariables.user_meta__wpdb__usermeta" />
|
||||
<exclude name="WordPress.VIP.PostsPerPage.posts_per_page_posts_per_page" />
|
||||
<exclude name="WordPress.VIP.RestrictedVariables.cache_constraints___COOKIE" />
|
||||
</rule>
|
||||
<rule ref="WordPress.VIP.ValidatedSanitizedInput">
|
||||
<properties>
|
||||
|
|
|
@ -10,15 +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/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.3.0
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.4.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
if ( $max_value && $min_value === $max_value ) {
|
||||
?>
|
||||
|
@ -27,10 +24,25 @@ if ( $max_value && $min_value === $max_value ) {
|
|||
</div>
|
||||
<?php
|
||||
} else {
|
||||
/* translators: %s: Quantity. */
|
||||
$labelledby = ! empty( $args['product_name'] ) ? sprintf( __( '%s quantity', 'woocommerce' ), strip_tags( $args['product_name'] ) ) : '';
|
||||
?>
|
||||
<div class="quantity">
|
||||
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></label>
|
||||
<input type="number" id="<?php echo esc_attr( $input_id ); ?>" class="input-text qty text" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( 0 < $max_value ? $max_value : '' ); ?>" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" aria-labelledby="<?php echo ! empty( $args['product_name'] ) ? sprintf( esc_attr__( '%s quantity', 'woocommerce' ), $args['product_name'] ) : ''; ?>" />
|
||||
<input
|
||||
type="number"
|
||||
id="<?php echo esc_attr( $input_id ); ?>"
|
||||
class="input-text qty text"
|
||||
step="<?php echo esc_attr( $step ); ?>"
|
||||
min="<?php echo esc_attr( $min_value ); ?>"
|
||||
max="<?php echo esc_attr( 0 < $max_value ? $max_value : '' ); ?>"
|
||||
name="<?php echo esc_attr( $input_name ); ?>"
|
||||
value="<?php echo esc_attr( $input_value ); ?>"
|
||||
title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ); ?>"
|
||||
size="4"
|
||||
pattern="<?php echo esc_attr( $pattern ); ?>"
|
||||
inputmode="<?php echo esc_attr( $inputmode ); ?>"
|
||||
aria-labelledby="<?php echo esc_attr( $labelledby ); ?>" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -22,28 +22,6 @@ class WC_Unit_Test_Case extends WP_UnitTestCase {
|
|||
*/
|
||||
protected $factory;
|
||||
|
||||
/**
|
||||
* Additional files, relative to the plugin's root directory, that should be explicitly included.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $includes;
|
||||
|
||||
/**
|
||||
* If a test has declared include files, load them before running the tests in the class.
|
||||
*
|
||||
* @beforeClass
|
||||
*/
|
||||
public static function include_dependencies() {
|
||||
$base_dir = trailingslashit( dirname( dirname( __DIR__ ) ) );
|
||||
|
||||
if ( ! empty( static::$includes ) ) {
|
||||
foreach ( (array) static::$includes as $include ) {
|
||||
include_once $base_dir . $include;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup test case.
|
||||
*
|
||||
|
|
|
@ -11,13 +11,12 @@
|
|||
class WC_Tests_Admin_Report extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Additional files, relative to the plugin's root directory, that should be explicitly included.
|
||||
* Load the necessary files, as they're not automatically loaded by WooCommerce.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $includes = array(
|
||||
'includes/admin/reports/class-wc-admin-report.php',
|
||||
);
|
||||
public static function setUpBeforeClass() {
|
||||
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-admin-report.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear cached report data.
|
||||
|
|
|
@ -11,14 +11,12 @@
|
|||
class WC_Tests_Report_Sales_By_Date extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Additional files, relative to the plugin's root directory, that should be explicitly included.
|
||||
*
|
||||
* @var array
|
||||
* Load the necessary files, as they're not automatically loaded by WooCommerce.
|
||||
*/
|
||||
protected static $includes = array(
|
||||
'includes/admin/reports/class-wc-admin-report.php',
|
||||
'includes/admin/reports/class-wc-report-sales-by-date.php',
|
||||
);
|
||||
public static function setUpBeforeClass() {
|
||||
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-admin-report.php';
|
||||
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-report-sales-by-date.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear cached report data.
|
||||
|
|
|
@ -9,7 +9,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
/**
|
||||
* Test some discount logic which has caused issues in the past.
|
||||
* Tickets:
|
||||
* https://github.com/woocommerce/woocommerce/issues/10573
|
||||
* https://github.com/woocommerce/woocommerce/issues/10573
|
||||
* https://github.com/woocommerce/woocommerce/issues/10963
|
||||
*
|
||||
* Due to discounts being split amongst products in cart.
|
||||
|
@ -162,11 +162,11 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
WC()->cart->empty_cart();
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
$product = new WC_Product_Simple;
|
||||
$product = new WC_Product_Simple();
|
||||
$product->set_regular_price( 51.86 );
|
||||
$product->save();
|
||||
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon = new WC_Coupon();
|
||||
$coupon->set_code( 'testpercent' );
|
||||
$coupon->set_discount_type( 'percent' );
|
||||
$coupon->set_amount( 40 );
|
||||
|
@ -263,24 +263,24 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
WC_Tax::_insert_tax_rate( $tax_rate );
|
||||
|
||||
// Create product.
|
||||
$product = new WC_Product_Simple;
|
||||
$product = new WC_Product_Simple();
|
||||
$product->set_regular_price( '9.99' );
|
||||
$product->save();
|
||||
|
||||
// Create coupons.
|
||||
$ten_coupon = new WC_Coupon;
|
||||
$ten_coupon = new WC_Coupon();
|
||||
$ten_coupon->set_code( '10off' );
|
||||
$ten_coupon->set_discount_type( 'percent' );
|
||||
$ten_coupon->set_amount( 10 );
|
||||
$ten_coupon->save();
|
||||
|
||||
$half_coupon = new WC_Coupon;
|
||||
$half_coupon = new WC_Coupon();
|
||||
$half_coupon->set_code( '50off' );
|
||||
$half_coupon->set_discount_type( 'percent' );
|
||||
$half_coupon->set_amount( 50 );
|
||||
$half_coupon->save();
|
||||
|
||||
$full_coupon = new WC_Coupon;
|
||||
$full_coupon = new WC_Coupon();
|
||||
$full_coupon->set_code( '100off' );
|
||||
$full_coupon->set_discount_type( 'percent' );
|
||||
$full_coupon->set_amount( 100 );
|
||||
|
@ -374,6 +374,125 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
update_option( 'woocommerce_calc_taxes', 'no' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test cart calculations when out of base location with no matching taxes and using inclusive taxes and discounts.
|
||||
*
|
||||
* @see GitHub issue #19390.
|
||||
* @since 3.3
|
||||
*/
|
||||
public function test_out_of_base_discounts_inclusive_tax_no_oob_tax() {
|
||||
global $wpdb;
|
||||
|
||||
// Set up tax options.
|
||||
update_option( 'woocommerce_prices_include_tax', 'yes' );
|
||||
update_option( 'woocommerce_calc_taxes', 'yes' );
|
||||
update_option( 'woocommerce_default_country', 'GB' );
|
||||
update_option( 'woocommerce_default_customer_address', 'base' );
|
||||
update_option( 'woocommerce_tax_based_on', 'shipping' );
|
||||
|
||||
// 20% tax for GB.
|
||||
$tax_rate = array(
|
||||
'tax_rate_country' => 'GB',
|
||||
'tax_rate_state' => '',
|
||||
'tax_rate' => '20.0000',
|
||||
'tax_rate_name' => 'VAT',
|
||||
'tax_rate_priority' => '1',
|
||||
'tax_rate_compound' => '0',
|
||||
'tax_rate_shipping' => '0',
|
||||
'tax_rate_order' => '1',
|
||||
'tax_rate_class' => '',
|
||||
);
|
||||
WC_Tax::_insert_tax_rate( $tax_rate );
|
||||
|
||||
// 0% tax everywhere else.
|
||||
$tax_rate = array(
|
||||
'tax_rate_country' => '',
|
||||
'tax_rate_state' => '',
|
||||
'tax_rate' => '0.0000',
|
||||
'tax_rate_name' => 'TAX',
|
||||
'tax_rate_priority' => '1',
|
||||
'tax_rate_compound' => '0',
|
||||
'tax_rate_shipping' => '0',
|
||||
'tax_rate_order' => '1',
|
||||
'tax_rate_class' => '',
|
||||
);
|
||||
WC_Tax::_insert_tax_rate( $tax_rate );
|
||||
|
||||
// Create product.
|
||||
$product = new WC_Product_Simple();
|
||||
$product->set_regular_price( '24.99' );
|
||||
$product->save();
|
||||
|
||||
// Create coupon.
|
||||
$ten_coupon = new WC_Coupon();
|
||||
$ten_coupon->set_code( '10off' );
|
||||
$ten_coupon->set_discount_type( 'percent' );
|
||||
$ten_coupon->set_amount( 10 );
|
||||
$ten_coupon->save();
|
||||
|
||||
$half_coupon = new WC_Coupon();
|
||||
$half_coupon->set_code( '50off' );
|
||||
$half_coupon->set_discount_type( 'percent' );
|
||||
$half_coupon->set_amount( 50 );
|
||||
$half_coupon->save();
|
||||
|
||||
$full_coupon = new WC_Coupon();
|
||||
$full_coupon->set_code( '100off' );
|
||||
$full_coupon->set_discount_type( 'percent' );
|
||||
$full_coupon->set_amount( 100 );
|
||||
$full_coupon->save();
|
||||
|
||||
add_filter( 'woocommerce_customer_get_shipping_country', array( $this, 'force_customer_us_shipping' ) );
|
||||
WC()->cart->add_to_cart( $product->get_id(), 1 );
|
||||
|
||||
// Test out of store location with no coupon.
|
||||
WC()->cart->calculate_totals();
|
||||
$this->assertEquals( '20.83', wc_format_decimal( WC()->cart->get_subtotal(), 2 ) );
|
||||
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_discount_total(), 2 ) );
|
||||
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_total_tax(), 2 ) );
|
||||
$this->assertEquals( '20.83', wc_format_decimal( WC()->cart->get_total( 'edit' ), 2 ) );
|
||||
|
||||
// Test out of store location with 10% coupon.
|
||||
WC()->cart->add_discount( $ten_coupon->get_code() );
|
||||
WC()->cart->calculate_totals();
|
||||
$this->assertEquals( '20.83', wc_format_decimal( WC()->cart->get_subtotal(), 2 ) );
|
||||
$this->assertEquals( '2.08', wc_format_decimal( WC()->cart->get_discount_total(), 2 ) );
|
||||
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_total_tax(), 2 ) );
|
||||
$this->assertEquals( '18.75', wc_format_decimal( WC()->cart->get_total( 'edit' ), 2 ) );
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Test out of store location with 50% coupon.
|
||||
WC()->cart->add_discount( $half_coupon->get_code() );
|
||||
WC()->cart->calculate_totals();
|
||||
$this->assertEquals( '20.83', wc_format_decimal( WC()->cart->get_subtotal(), 2 ) );
|
||||
$this->assertEquals( '10.41', wc_format_decimal( WC()->cart->get_discount_total(), 2 ) );
|
||||
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_total_tax(), 2 ) );
|
||||
$this->assertEquals( '10.42', wc_format_decimal( WC()->cart->get_total( 'edit' ), 2 ) );
|
||||
WC()->cart->remove_coupons();
|
||||
|
||||
// Test out of store location with 100% coupon.
|
||||
WC()->cart->add_discount( $full_coupon->get_code() );
|
||||
WC()->cart->calculate_totals();
|
||||
$this->assertEquals( '20.83', wc_format_decimal( WC()->cart->get_subtotal(), 2 ) );
|
||||
$this->assertEquals( '20.83', wc_format_decimal( WC()->cart->get_discount_total(), 2 ), 'Discount total out of base' );
|
||||
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_total_tax(), 2 ) );
|
||||
$this->assertEquals( '0.00', wc_format_decimal( WC()->cart->get_total( 'edit' ), 2 ) );
|
||||
|
||||
// Clean up.
|
||||
WC()->cart->empty_cart();
|
||||
WC()->cart->remove_coupons();
|
||||
remove_filter( 'woocommerce_customer_get_shipping_country', array( $this, 'force_customer_us_shipping' ) );
|
||||
WC_Helper_Product::delete_product( $product->get_id() );
|
||||
WC_Helper_Coupon::delete_coupon( $ten_coupon->get_id() );
|
||||
WC_Helper_Coupon::delete_coupon( $half_coupon->get_id() );
|
||||
WC_Helper_Coupon::delete_coupon( $full_coupon->get_id() );
|
||||
$wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rates" );
|
||||
$wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations" );
|
||||
update_option( 'woocommerce_prices_include_tax', 'no' );
|
||||
update_option( 'woocommerce_calc_taxes', 'no' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper that can be hooked to a filter to force the customer's shipping country to be GB.
|
||||
*
|
||||
|
@ -443,7 +562,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
}
|
||||
|
||||
// Create the product and add it to the cart.
|
||||
$product = new WC_Product_Simple;
|
||||
$product = new WC_Product_Simple();
|
||||
$product->set_regular_price( '149.14' );
|
||||
$product->save();
|
||||
WC()->cart->add_to_cart( $product->get_id(), 1 );
|
||||
|
@ -503,11 +622,11 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
|
||||
// Add 2 products whose retail prices (inc tax) are: £65, £50.
|
||||
// Their net prices are therefore: £54.1666667 and £41.6666667.
|
||||
$product1 = new WC_Product_Simple;
|
||||
$product1 = new WC_Product_Simple();
|
||||
$product1->set_regular_price( '54.1666667' );
|
||||
$product1->save();
|
||||
|
||||
$product2 = new WC_Product_Simple;
|
||||
$product2 = new WC_Product_Simple();
|
||||
$product2->set_regular_price( '41.6666667' );
|
||||
$product2->save();
|
||||
|
||||
|
@ -1191,7 +1310,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_add_discount_code_id() {
|
||||
|
||||
$coupon = new WC_Coupon;
|
||||
$coupon = new WC_Coupon();
|
||||
$coupon->set_code( 'test' );
|
||||
$coupon->set_amount( 100 );
|
||||
$coupon->save();
|
||||
|
@ -1421,4 +1540,16 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
$wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_tax_rate_locations" );
|
||||
update_option( 'woocommerce_calc_taxes', 'no' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test is_coupon_emails_allowed function on the cart, specifically test wildcard emails.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test_is_coupon_emails_allowed() {
|
||||
$this->assertEquals( true, WC()->cart->is_coupon_emails_allowed( array( 'customer@wc.local' ), array( '*.local' ) ) );
|
||||
$this->assertEquals( false, WC()->cart->is_coupon_emails_allowed( array( 'customer@wc.local' ), array( '*.test' ) ) );
|
||||
$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' ) ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,33 +106,33 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
|
|||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_is_GB_postcode.
|
||||
* Data provider for test_is_gb_postcode.
|
||||
*
|
||||
* @since 2.4
|
||||
*/
|
||||
public function data_provider_test_is_GB_postcode() {
|
||||
public function data_provider_test_is_gb_postcode() {
|
||||
return array(
|
||||
array( true, WC_Validation::is_GB_postcode( 'AA9A 9AA' ) ),
|
||||
array( true, WC_Validation::is_GB_postcode( 'A9A 9AA' ) ),
|
||||
array( true, WC_Validation::is_GB_postcode( 'A9 9AA' ) ),
|
||||
array( true, WC_Validation::is_GB_postcode( 'A99 9AA' ) ),
|
||||
array( true, WC_Validation::is_GB_postcode( 'AA99 9AA' ) ),
|
||||
array( true, WC_Validation::is_GB_postcode( 'BFPO 801' ) ),
|
||||
array( false, WC_Validation::is_GB_postcode( '99999' ) ),
|
||||
array( false, WC_Validation::is_GB_postcode( '9999 999' ) ),
|
||||
array( false, WC_Validation::is_GB_postcode( '999 999' ) ),
|
||||
array( false, WC_Validation::is_GB_postcode( '99 999' ) ),
|
||||
array( false, WC_Validation::is_GB_postcode( '9A A9A' ) ),
|
||||
array( true, WC_Validation::is_gb_postcode( 'AA9A 9AA' ) ),
|
||||
array( true, WC_Validation::is_gb_postcode( 'A9A 9AA' ) ),
|
||||
array( true, WC_Validation::is_gb_postcode( 'A9 9AA' ) ),
|
||||
array( true, WC_Validation::is_gb_postcode( 'A99 9AA' ) ),
|
||||
array( true, WC_Validation::is_gb_postcode( 'AA99 9AA' ) ),
|
||||
array( true, WC_Validation::is_gb_postcode( 'BFPO 801' ) ),
|
||||
array( false, WC_Validation::is_gb_postcode( '99999' ) ),
|
||||
array( false, WC_Validation::is_gb_postcode( '9999 999' ) ),
|
||||
array( false, WC_Validation::is_gb_postcode( '999 999' ) ),
|
||||
array( false, WC_Validation::is_gb_postcode( '99 999' ) ),
|
||||
array( false, WC_Validation::is_gb_postcode( '9A A9A' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test is_GB_postcode().
|
||||
* Test is_gb_postcode().
|
||||
*
|
||||
* @dataProvider data_provider_test_is_GB_postcode
|
||||
* @dataProvider data_provider_test_is_gb_postcode
|
||||
* @since 2.4
|
||||
*/
|
||||
public function test_is_GB_postcode( $assert, $values ) {
|
||||
public function test_is_gb_postcode( $assert, $values ) {
|
||||
$this->assertEquals( $assert, $values );
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) {
|
|||
|
||||
// Delete options.
|
||||
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'woocommerce\_%';" );
|
||||
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'widget\_woocommerce\_%';" );
|
||||
|
||||
// Delete usermeta.
|
||||
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE 'woocommerce\_%';" );
|
||||
|
@ -57,6 +58,10 @@ if ( defined( 'WC_REMOVE_ALL_DATA' ) && true === WC_REMOVE_ALL_DATA ) {
|
|||
// Delete posts + data.
|
||||
$wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ( 'product', 'product_variation', 'shop_coupon', 'shop_order', 'shop_order_refund' );" );
|
||||
$wpdb->query( "DELETE meta FROM {$wpdb->postmeta} meta LEFT JOIN {$wpdb->posts} posts ON posts.ID = meta.post_id WHERE posts.ID IS NULL;" );
|
||||
|
||||
$wpdb->query( "DELETE FROM {$wpdb->comments} WHERE comment_type IN ( 'order_note' );" );
|
||||
$wpdb->query( "DELETE meta FROM {$wpdb->commentmeta} meta LEFT JOIN {$wpdb->comments} comments ON comments.comment_ID = meta.comment_id WHERE comments.comment_ID IS NULL;" );
|
||||
|
||||
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_items" );
|
||||
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}woocommerce_order_itemmeta" );
|
||||
|
||||
|
|
Loading…
Reference in New Issue