Merge branch 'master' into shipping-zones

# Conflicts:
#	assets/css/admin.css
#	includes/abstracts/abstract-wc-shipping-method.php
#	includes/class-wc-shipping.php
#	includes/shipping/flat-rate/class-wc-shipping-flat-rate.php
#	includes/shipping/flat-rate/includes/class-wc-eval-math.php
#	includes/shipping/free-shipping/class-wc-shipping-free-shipping.php
#
includes/shipping/legacy-international-delivery/class-wc-shipping-legacy
-international-delivery.php
#
includes/shipping/legacy-local-delivery/class-wc-shipping-legacy-local-d
elivery.php
This commit is contained in:
Mike Jolley 2016-01-11 11:48:18 +00:00
commit 1076854608
125 changed files with 3182 additions and 2172 deletions

File diff suppressed because one or more lines are too long

View File

@ -3178,7 +3178,8 @@ img.help_tip {
input[type="text"],
input[type="email"],
input[type="number"] {
input[type="number"],
input[type="password"] {
width: 50%;
float: left;
}
@ -3195,6 +3196,7 @@ img.help_tip {
input[type="text"].short,
input[type="email"].short,
input[type="number"].short,
input[type="password"].short,
.short {
width: 50%;
}

View File

@ -131,12 +131,12 @@ jQuery( function( $ ) {
// Hide/Show all with rules
var hide_classes = '.hide_if_downloadable, .hide_if_virtual';
var show_classes = '.show_if_downloadable, .show_if_virtual, .show_if_external';
var show_classes = '.show_if_downloadable, .show_if_virtual';
$.each( woocommerce_admin_meta_boxes.product_types, function( index, value ) {
hide_classes = hide_classes + ', .hide_if_' + value;
show_classes = show_classes + ', .show_if_' + value;
} );
});
$( hide_classes ).show();
$( show_classes ).hide();

File diff suppressed because one or more lines are too long

View File

@ -62,7 +62,6 @@ jQuery( function( $ ) {
var wc_country_select_select2 = function() {
$( 'select.country_select:visible, select.state_select:visible' ).each( function() {
var select2_args = $.extend({
placeholder: $( this ).attr( 'placeholder' ),
placeholderOption: 'first',
width: '100%'
}, getEnhancedSelectFormatString() );
@ -91,7 +90,7 @@ jQuery( function( $ ) {
input_name = $statebox.attr( 'name' ),
input_id = $statebox.attr( 'id' ),
value = $statebox.val(),
placeholder = $statebox.attr( 'placeholder' );
placeholder = $statebox.attr( 'placeholder' ) || $statebox.attr( 'data-placeholder' ) || '';
if ( states[ country ] ) {
if ( $.isEmptyObject( states[ country ] ) ) {
@ -116,7 +115,7 @@ jQuery( function( $ ) {
if ( $statebox.is( 'input' ) ) {
// Change for select
$statebox.replaceWith( '<select name="' + input_name + '" id="' + input_id + '" class="state_select" placeholder="' + placeholder + '"></select>' );
$statebox.replaceWith( '<select name="' + input_name + '" id="' + input_id + '" class="state_select" data-placeholder="' + placeholder + '"></select>' );
$statebox = $wrapper.find( '#billing_state, #shipping_state, #calc_shipping_state' );
}

View File

@ -1 +1 @@
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_country_select_params.i18n_matches_1:wc_country_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_country_select_params.i18n_no_matches},formatAjaxError:function(){return wc_country_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_country_select_params.i18n_load_more},formatSearching:function(){return wc_country_select_params.i18n_searching}};return a}if("undefined"==typeof wc_country_select_params)return!1;if(a().select2){var c=function(){a("select.country_select:visible, select.state_select:visible").each(function(){var c=a.extend({placeholder:a(this).attr("placeholder"),placeholderOption:"first",width:"100%"},b());a(this).select2(c)})};c(),a(document.body).bind("country_to_state_changed",function(){c()})}var d=wc_country_select_params.countries.replace(/&quot;/g,'"'),e=a.parseJSON(d);a(document.body).on("change","select.country_to_state, input.country_to_state",function(){var b=a(this).val(),c=a(this).closest(".form-row").parent(),d=c.find("#billing_state, #shipping_state, #calc_shipping_state"),f=d.parent(),g=d.attr("name"),h=d.attr("id"),i=d.val(),j=d.attr("placeholder");if(e[b])if(a.isEmptyObject(e[b]))d.parent().hide().find(".select2-container").remove(),d.replaceWith('<input type="hidden" class="hidden" name="'+g+'" id="'+h+'" value="" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[b,c]);else{var k="",l=e[b];for(var m in l)l.hasOwnProperty(m)&&(k=k+'<option value="'+m+'">'+l[m]+"</option>");d.parent().show(),d.is("input")&&(d.replaceWith('<select name="'+g+'" id="'+h+'" class="state_select" placeholder="'+j+'"></select>'),d=c.find("#billing_state, #shipping_state, #calc_shipping_state")),d.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+k),d.val(i).change(),a(document.body).trigger("country_to_state_changed",[b,c])}else d.is("select")?(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[b,c])):d.is(".hidden")&&(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[b,c]));a(document.body).trigger("country_to_state_changing",[b,c])}),a(function(){a(":input.country_to_state").change()})});
jQuery(function(a){function b(){var a={formatMatches:function(a){return 1===a?wc_country_select_params.i18n_matches_1:wc_country_select_params.i18n_matches_n.replace("%qty%",a)},formatNoMatches:function(){return wc_country_select_params.i18n_no_matches},formatAjaxError:function(){return wc_country_select_params.i18n_ajax_error},formatInputTooShort:function(a,b){var c=b-a.length;return 1===c?wc_country_select_params.i18n_input_too_short_1:wc_country_select_params.i18n_input_too_short_n.replace("%qty%",c)},formatInputTooLong:function(a,b){var c=a.length-b;return 1===c?wc_country_select_params.i18n_input_too_long_1:wc_country_select_params.i18n_input_too_long_n.replace("%qty%",c)},formatSelectionTooBig:function(a){return 1===a?wc_country_select_params.i18n_selection_too_long_1:wc_country_select_params.i18n_selection_too_long_n.replace("%qty%",a)},formatLoadMore:function(){return wc_country_select_params.i18n_load_more},formatSearching:function(){return wc_country_select_params.i18n_searching}};return a}if("undefined"==typeof wc_country_select_params)return!1;if(a().select2){var c=function(){a("select.country_select:visible, select.state_select:visible").each(function(){var c=a.extend({placeholderOption:"first",width:"100%"},b());a(this).select2(c)})};c(),a(document.body).bind("country_to_state_changed",function(){c()})}var d=wc_country_select_params.countries.replace(/&quot;/g,'"'),e=a.parseJSON(d);a(document.body).on("change","select.country_to_state, input.country_to_state",function(){var b=a(this).val(),c=a(this).closest(".form-row").parent(),d=c.find("#billing_state, #shipping_state, #calc_shipping_state"),f=d.parent(),g=d.attr("name"),h=d.attr("id"),i=d.val(),j=d.attr("placeholder")||d.attr("data-placeholder")||"";if(e[b])if(a.isEmptyObject(e[b]))d.parent().hide().find(".select2-container").remove(),d.replaceWith('<input type="hidden" class="hidden" name="'+g+'" id="'+h+'" value="" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[b,c]);else{var k="",l=e[b];for(var m in l)l.hasOwnProperty(m)&&(k=k+'<option value="'+m+'">'+l[m]+"</option>");d.parent().show(),d.is("input")&&(d.replaceWith('<select name="'+g+'" id="'+h+'" class="state_select" data-placeholder="'+j+'"></select>'),d=c.find("#billing_state, #shipping_state, #calc_shipping_state")),d.html('<option value="">'+wc_country_select_params.i18n_select_state_text+"</option>"+k),d.val(i).change(),a(document.body).trigger("country_to_state_changed",[b,c])}else d.is("select")?(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[b,c])):d.is(".hidden")&&(f.show().find(".select2-container").remove(),d.replaceWith('<input type="text" class="input-text" name="'+g+'" id="'+h+'" placeholder="'+j+'" />'),a(document.body).trigger("country_to_state_changed",[b,c]));a(document.body).trigger("country_to_state_changing",[b,c])}),a(function(){a(":input.country_to_state").change()})});

File diff suppressed because it is too large Load Diff

View File

@ -96,7 +96,7 @@ abstract class WC_Abstract_Order {
* should be used. It is possible, but the aforementioned are preferred and are the only.
* methods that will be maintained going forward.
*
* @param int $order
* @param int|object|WC_Order $order Order to init.
*/
public function __construct( $order = 0 ) {
$this->prices_include_tax = get_option('woocommerce_prices_include_tax') == 'yes' ? true : false;
@ -147,7 +147,6 @@ abstract class WC_Abstract_Order {
/**
* Set the payment method for the order.
*
* @param WC_Payment_Gateway
* @param WC_Payment_Gateway $payment_method
*/
public function set_payment_method( $payment_method ) {
@ -337,8 +336,8 @@ abstract class WC_Abstract_Order {
* Add coupon code to the order.
*
* @param string $code
* @param integer $discount_amount
* @param integer $discount_amount_tax "Discounted" tax - used for tax inclusive prices.
* @param int $discount_amount
* @param int $discount_amount_tax "Discounted" tax - used for tax inclusive prices.
* @return int|bool Item ID or false.
*/
public function add_coupon( $code, $discount_amount = 0, $discount_amount_tax = 0 ) {
@ -812,7 +811,7 @@ abstract class WC_Abstract_Order {
* Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total.
*
* @since 2.2
* @param $and_taxes bool Calc taxes if true.
* @param bool $and_taxes Calc taxes if true.
* @return float calculated grand total.
*/
public function calculate_totals( $and_taxes = true ) {
@ -1373,7 +1372,7 @@ abstract class WC_Abstract_Order {
/**
* Gets the total discount amount.
* @param $ex_tax Show discount excl any tax.
* @param bool $ex_tax Show discount excl any tax.
* @return float
*/
public function get_total_discount( $ex_tax = true ) {
@ -1834,6 +1833,7 @@ abstract class WC_Abstract_Order {
/**
* Get totals for display on pages and in emails.
*
* @param mixed $tax_display
* @return array
*/
public function get_order_item_totals( $tax_display = '' ) {
@ -2027,7 +2027,7 @@ abstract class WC_Abstract_Order {
/**
* Generates a URL so that a customer can pay for their (unpaid - pending) order. Pass 'true' for the checkout version which doesn't offer gateway choices.
*
* @param boolean $on_checkout
* @param bool $on_checkout
* @return string
*/
public function get_checkout_payment_url( $on_checkout = false ) {
@ -2350,7 +2350,7 @@ abstract class WC_Abstract_Order {
* Sales are also recorded for products.
* Finally, record the date of payment.
*
* @param $transaction_id string Optional transaction id to store in post meta.
* @param string $transaction_id Optional transaction id to store in post meta.
*/
public function payment_complete( $transaction_id = '' ) {
do_action( 'woocommerce_pre_payment_complete', $this->id );
@ -2382,7 +2382,7 @@ abstract class WC_Abstract_Order {
add_post_meta( $this->id, '_paid_date', current_time( 'mysql' ), true );
if ( ! empty( $transaction_id ) ) {
add_post_meta( $this->id, '_transaction_id', $transaction_id, true );
update_post_meta( $this->id, '_transaction_id', $transaction_id );
}
wp_update_post( array(

View File

@ -212,7 +212,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
}
/**
* has_fields function.
* Check if the gateway has fields on the checkout.
*
* @return bool
*/
@ -239,7 +239,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
}
/**
* get_icon function.
* Return the gateway's icon.
*
* @return string
*/
@ -296,6 +296,8 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* Validate frontend fields.
*
* Validate payment fields on the frontend.
*
* @return bool
*/
public function validate_fields() { return true; }
@ -332,6 +334,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* Core credit card form which gateways can used if needed.
*
* @param array $args
* @param array $fields
*/
public function credit_card_form( $args = array(), $fields = array() ) {

View File

@ -178,7 +178,7 @@ class WC_Product {
}
/**
* get_gallery_attachment_ids function.
* Returns the gallery attachment ids.
*
* @return array
*/
@ -319,7 +319,7 @@ class WC_Product {
}
/**
* set_stock_status function.
* Set stock status of the product.
*
* @param string $status
*/
@ -493,17 +493,17 @@ class WC_Product {
}
/**
* get_child function.
* Returns the child product.
*
* @param mixed $child_id
* @return WC_Product WC_Product or WC_Product_variation
* @return WC_Product|WC_Product|WC_Product_variation
*/
public function get_child( $child_id ) {
return wc_get_product( $child_id );
}
/**
* get_children function.
* Returns the children.
*
* @return array
*/
@ -845,6 +845,7 @@ class WC_Product {
/**
* Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes.
*
* @param int $qty
* @param string $price to calculate, left blank to just use get_price()
* @return string
*/
@ -904,6 +905,7 @@ class WC_Product {
* Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting.
* Uses store base tax rates. Can work for a specific $qty for more accurate taxes.
*
* @param int $qty
* @param string $price to calculate, left blank to just use get_price()
* @return string
*/
@ -1505,6 +1507,7 @@ class WC_Product {
* Returns the main product image.
*
* @param string $size (default: 'shop_thumbnail')
* @param array $attr
* @return string
*/
public function get_image( $size = 'shop_thumbnail', $attr = array() ) {

View File

@ -63,7 +63,10 @@ abstract class WC_Widget extends WP_Widget {
}
/**
* get_cached_widget function.
* Get cached widget.
*
* @param array $args
* @return bool true if the widget is cached otherwise false
*/
public function get_cached_widget( $args ) {
@ -126,7 +129,7 @@ abstract class WC_Widget extends WP_Widget {
}
/**
* update function.
* Updates a particular instance of a widget.
*
* @see WP_Widget->update
* @param array $new_instance
@ -183,7 +186,7 @@ abstract class WC_Widget extends WP_Widget {
}
/**
* form function.
* Outputs the settings update form.
*
* @see WP_Widget->form
* @param array $instance

View File

@ -50,7 +50,10 @@ class WC_Admin_Addons {
}
/**
* Get section for the addons screen
* Get section for the addons screen.
*
* @param string $section_id
*
* @return object|bool
*/
public static function get_section( $section_id ) {
@ -62,7 +65,10 @@ class WC_Admin_Addons {
}
/**
* Get section content for the addons screen
* Get section content for the addons screen.
*
* @param string $section_id
*
* @return array
*/
public static function get_section_data( $section_id ) {

View File

@ -236,6 +236,9 @@ class WC_Admin_Menus {
add_meta_box( 'woocommerce_endpoints_nav_link', __( 'WooCommerce Endpoints', 'woocommerce' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
}
/**
* Output menu links.
*/
public function nav_menu_links() {
$exclude = array( 'view-order', 'add-payment-method', 'order-pay', 'order-received' );
?>

View File

@ -19,7 +19,18 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Admin_Meta_Boxes {
/**
* Is meta boxes saved once?
*
* @var boolean
*/
private static $saved_meta_boxes = false;
/**
* Meta box error messages.
*
* @var array
*/
public static $meta_box_errors = array();
/**
@ -198,7 +209,7 @@ class WC_Admin_Meta_Boxes {
// We need this save event to run once to avoid potential endless loops. This would have been perfect:
// remove_action( current_filter(), __METHOD__ );
// But cannot be used due to https://github.com/woothemes/woocommerce/issues/6485
// When that is patched in core we cna use the above. For now:
// When that is patched in core we can use the above. For now:
self::$saved_meta_boxes = true;
// Check the post type

View File

@ -1533,38 +1533,43 @@ class WC_Admin_Post_Types {
) ) );
$search_order_id = str_replace( 'Order #', '', $_GET['s'] );
if ( ! is_numeric( $search_order_id ) ) {
$search_order_id = 0;
}
// Search orders
$post_ids = array_unique( array_merge(
$wpdb->get_col(
$wpdb->prepare( "
SELECT DISTINCT p1.post_id
FROM {$wpdb->postmeta} p1
INNER JOIN {$wpdb->postmeta} p2 ON p1.post_id = p2.post_id
WHERE
( p1.meta_key = '_billing_first_name' AND p2.meta_key = '_billing_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key = '_shipping_first_name' AND p2.meta_key = '_shipping_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key IN ('" . implode( "','", $search_fields ) . "') AND p1.meta_value LIKE '%%%s%%' )
",
esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] )
if ( is_numeric( $search_order_id ) ) {
$post_ids = array_unique( array_merge(
$wpdb->get_col(
$wpdb->prepare( "SELECT DISTINCT p1.post_id FROM {$wpdb->postmeta} p1 WHERE p1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', $search_fields ) ) . "') AND p1.meta_value LIKE '%%%d%%';", absint( $search_order_id ) )
),
array( absint( $search_order_id ) )
) );
} else {
$post_ids = array_unique( array_merge(
$wpdb->get_col(
$wpdb->prepare( "
SELECT DISTINCT p1.post_id
FROM {$wpdb->postmeta} p1
INNER JOIN {$wpdb->postmeta} p2 ON p1.post_id = p2.post_id
WHERE
( p1.meta_key = '_billing_first_name' AND p2.meta_key = '_billing_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key = '_shipping_first_name' AND p2.meta_key = '_shipping_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key IN ('" . implode( "','", array_map( 'esc_sql', $search_fields ) ) . "') AND p1.meta_value LIKE '%%%s%%' )
",
wc_clean( $_GET['s'] ), wc_clean( $_GET['s'] ), wc_clean( $_GET['s'] )
)
),
$wpdb->get_col(
$wpdb->prepare( "
SELECT order_id
FROM {$wpdb->prefix}woocommerce_order_items as order_items
WHERE order_item_name LIKE '%%%s%%'
",
wc_clean( $_GET['s'] )
)
)
),
$wpdb->get_col(
$wpdb->prepare( "
SELECT order_id
FROM {$wpdb->prefix}woocommerce_order_items as order_items
WHERE order_item_name LIKE '%%%s%%'
",
esc_attr( $_GET['s'] )
)
),
array( $search_order_id )
) );
) );
}
// Remove s - we don't want to search order name
unset( $wp->query_vars['s'] );

View File

@ -19,8 +19,25 @@ if ( ! class_exists( 'WC_Admin_Settings' ) ) :
*/
class WC_Admin_Settings {
/**
* Setting pages.
*
* @var array
*/
private static $settings = array();
/**
* Error messages.
*
* @var array
*/
private static $errors = array();
/**
* Update messages.
*
* @var array
*/
private static $messages = array();
/**

View File

@ -308,7 +308,7 @@ class WC_Admin_Setup_Wizard {
<option value=""><?php _e( 'Choose a currency&hellip;', 'woocommerce' ); ?></option>
<?php
foreach ( get_woocommerce_currencies() as $code => $name ) {
echo '<option value="' . esc_attr( $code ) . '" ' . checked( $currency, $code, false ) . '>' . esc_html( $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')' ) . '</option>';
echo '<option value="' . esc_attr( $code ) . '" ' . selected( $currency, $code, false ) . '>' . esc_html( $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')' ) . '</option>';
}
?>
</select>

View File

@ -57,7 +57,7 @@ class WC_Admin_Taxonomies {
*
* @param mixed $term_id
* @param mixed $tt_id
* @param mixed $taxonomy
* @param string $taxonomy
*/
public function create_term( $term_id, $tt_id = '', $taxonomy = '' ) {
if ( 'product_cat' != $taxonomy && ! taxonomy_is_product_attribute( $taxonomy ) ) {
@ -257,6 +257,8 @@ class WC_Admin_Taxonomies {
* save_category_fields function.
*
* @param mixed $term_id Term ID being saved
* @param mixed $tt_id
* @param string $taxonomy
*/
public function save_category_fields( $term_id, $tt_id = '', $taxonomy = '' ) {
if ( isset( $_POST['display_type'] ) && 'product_cat' === $taxonomy ) {
@ -307,9 +309,9 @@ class WC_Admin_Taxonomies {
/**
* Thumbnail column value added to category admin.
*
* @param mixed $columns
* @param mixed $column
* @param mixed $id
* @param string $columns
* @param string $column
* @param int $id
* @return array
*/
public function product_cat_column( $columns, $column, $id ) {

View File

@ -17,9 +17,32 @@ if ( ! class_exists( 'WP_Importer' ) ) {
*/
class WC_Tax_Rate_Importer extends WP_Importer {
/**
* The current file id.
*
* @var int
*/
public $id;
/**
* The current file url.
*
* @var string
*/
public $file_url;
/**
* The current import page.
*
* @var string
*/
public $import_page;
/**
* The current delimiter.
*
* @var string
*/
public $delimiter;
/**
@ -84,7 +107,7 @@ class WC_Tax_Rate_Importer extends WP_Importer {
}
/**
* format_data_from_csv function.
* UTF-8 encode the data if `$enc` value isn't UTF-8.
*
* @param mixed $data
* @param string $enc
@ -95,7 +118,7 @@ class WC_Tax_Rate_Importer extends WP_Importer {
}
/**
* import function.
* Import the file if it exists and is valid.
*
* @param mixed $file
*/
@ -186,7 +209,7 @@ class WC_Tax_Rate_Importer extends WP_Importer {
}
/**
* header function.
* Output header html.
*/
public function header() {
echo '<div class="wrap"><div class="icon32 icon32-woocommerce-importer" id="icon-woocommerce"><br></div>';
@ -194,14 +217,14 @@ class WC_Tax_Rate_Importer extends WP_Importer {
}
/**
* footer function.
* Output footer html.
*/
public function footer() {
echo '</div>';
}
/**
* greet function.
* Output information about the uploading process.
*/
public function greet() {

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Coupon_Data {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
@ -209,6 +211,9 @@ class WC_Meta_Box_Coupon_Data {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
global $wpdb;

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Order_Actions {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
global $theorder;
@ -90,6 +92,9 @@ class WC_Meta_Box_Order_Actions {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
@ -147,7 +152,7 @@ class WC_Meta_Box_Order_Actions {
/**
* Set the correct message ID.
*
* @param $location
* @param string $location
*
* @since 2.3.0
*

View File

@ -133,6 +133,8 @@ class WC_Meta_Box_Order_Data {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
global $theorder;
@ -401,6 +403,9 @@ class WC_Meta_Box_Order_Data {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
global $wpdb;

View File

@ -19,6 +19,8 @@ class WC_Meta_Box_Order_Downloads {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
global $post, $wpdb;
@ -77,6 +79,9 @@ class WC_Meta_Box_Order_Downloads {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
global $wpdb;

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Order_Items {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
global $post, $thepostid, $theorder;
@ -41,6 +43,9 @@ class WC_Meta_Box_Order_Items {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
wc_save_order_items( $post_id, $_POST );

View File

@ -19,6 +19,8 @@ class WC_Meta_Box_Order_Notes {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
global $post;

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Order_Reviews {
/**
* Output the metabox.
*
* @param WP_Comment $comment
*/
public static function output( $comment ) {
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
@ -37,6 +39,9 @@ class WC_Meta_Box_Order_Reviews {
/**
* Save meta box data.
*
* @param string $location
* @param int $comment_id
*/
public static function save( $location, $comment_id ) {
// Not allowed, return regular value without updating meta

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Product_Data {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
global $post, $thepostid;
@ -1233,6 +1235,8 @@ class WC_Meta_Box_Product_Data {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save_variations( $post_id, $post ) {
global $wpdb;

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Product_Images {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {
?>
@ -81,6 +83,9 @@ class WC_Meta_Box_Product_Images {
/**
* Save meta box data.
*
* @param int $post_id
* @param WP_Post $post
*/
public static function save( $post_id, $post ) {
$attachment_ids = isset( $_POST['product_image_gallery'] ) ? array_filter( explode( ',', wc_clean( $_POST['product_image_gallery'] ) ) ) : array();

View File

@ -21,6 +21,8 @@ class WC_Meta_Box_Product_Short_Description {
/**
* Output the metabox.
*
* @param WP_Post $post
*/
public static function output( $post ) {

View File

@ -16,11 +16,46 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Admin_Report {
/**
* The chart interval.
*
* @var int
*/
public $chart_interval;
/**
* Group by SQL query.
*
* @var string
*/
public $group_by_query;
/**
* The bar width.
*
* @var int
*/
public $barwidth;
/**
* Group chart item by day or month.
*
* @var string
*/
public $chart_groupby;
/**
* The start date of the report.
*
* @var string
*/
public $start_date;
/**
* The end date of the report.
*
* @var string
*/
public $end_date;
/**
@ -316,7 +351,7 @@ class WC_Admin_Report {
* @param int $interval
* @param string $start_date
* @param string $group_by
* @return string
* @return array
*/
public function prepare_chart_data( $data, $date_key, $data_key, $interval, $start_date, $group_by ) {
$prepared_data = array();
@ -575,7 +610,7 @@ class WC_Admin_Report {
}
/**
* [get_chart_widgets description].
* Get chart widgets.
*
* @return array
*/

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Coupon_Usage
*
@ -10,11 +15,15 @@
class WC_Report_Coupon_Usage extends WC_Admin_Report {
/**
* Chart colours.
*
* @var array
*/
public $chart_colours = array();
/**
* Coupon codes.
*
* @var array
*/
public $coupon_codes = array();
@ -139,7 +148,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
}
/**
* [get_chart_widgets description].
* Get chart widgets.
*
* @return array
*/
@ -155,7 +164,7 @@ class WC_Report_Coupon_Usage extends WC_Admin_Report {
}
/**
* Product selection.
* Output coupons widget.
*/
public function coupons_widget() {
?>

View File

@ -19,7 +19,7 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
class WC_Report_Customer_List extends WP_List_Table {
/**
* __construct function.
* Constructor.
*/
public function __construct() {
@ -71,13 +71,13 @@ class WC_Report_Customer_List extends WP_List_Table {
}
/**
* column_default function.
* Get column value.
*
* @param WP_User $user
* @param string $column_name
* @return string
*/
function column_default( $user, $column_name ) {
public function column_default( $user, $column_name ) {
global $wpdb;
switch ( $column_name ) {
@ -221,9 +221,11 @@ class WC_Report_Customer_List extends WP_List_Table {
}
/**
* get_columns function.
* Get columns.
*
* @return array
*/
public function get_columns(){
public function get_columns() {
$columns = array(
'customer_name' => __( 'Name (Last, First)', 'woocommerce' ),
'username' => __( 'Username', 'woocommerce' ),
@ -240,6 +242,8 @@ class WC_Report_Customer_List extends WP_List_Table {
/**
* Order users by name.
*
* @param WP_User_Query $query
*/
public function order_by_last_name( $query ) {
global $wpdb;
@ -260,7 +264,7 @@ class WC_Report_Customer_List extends WP_List_Table {
}
/**
* prepare_items function.
* Prepare customer list items.
*/
public function prepare_items() {
global $wpdb;

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Customers
*
@ -9,7 +14,18 @@
*/
class WC_Report_Customers extends WC_Admin_Report {
/**
* Chart colours.
*
* @var array
*/
public $chart_colours = array();
/**
* Customers.
*
* @var array
*/
public $customers = array();
/**
@ -30,7 +46,7 @@ class WC_Report_Customers extends WC_Admin_Report {
}
/**
* [get_chart_widgets description].
* Get chart widgets.
*
* @return array
*/
@ -46,7 +62,7 @@ class WC_Report_Customers extends WC_Admin_Report {
}
/**
* customers_vs_guests.
* Output customers vs guests chart.
*/
public function customers_vs_guests() {
@ -216,9 +232,7 @@ class WC_Report_Customers extends WC_Admin_Report {
}
/**
* Get the main chart.
*
* @return string
* Output the main chart.
*/
public function get_main_chart() {
global $wp_locale;

View File

@ -27,6 +27,9 @@ class WC_Report_Low_In_Stock extends WC_Report_Stock {
/**
* Get Products matching stock criteria.
*
* @param int $current_page
* @param int $per_page
*/
public function get_items( $current_page, $per_page ) {
global $wpdb;

View File

@ -20,6 +20,9 @@ class WC_Report_Most_Stocked extends WC_Report_Stock {
/**
* Get Products matching stock criteria.
*
* @param int $current_page
* @param int $per_page
*/
public function get_items( $current_page, $per_page ) {
global $wpdb;

View File

@ -27,6 +27,9 @@ class WC_Report_Out_Of_Stock extends WC_Report_Stock {
/**
* Get Products matching stock criteria.
*
* @param int $current_page
* @param int $per_page
*/
public function get_items( $current_page, $per_page ) {
global $wpdb;

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Sales_By_Category
*
@ -9,9 +14,32 @@
*/
class WC_Report_Sales_By_Category extends WC_Admin_Report {
/**
* Chart colours.
*
* @var array
*/
public $chart_colours = array();
/**
* Categories ids.
*
* @var array
*/
public $show_categories = array();
/**
* Item sales.
*
* @var array
*/
private $item_sales = array();
/**
* Item sales and times.
*
* @var array
*/
private $item_sales_and_times = array();
/**
@ -153,7 +181,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
}
/**
* [get_chart_widgets description].
* Get chart widgets.
*
* @return array
*/
@ -168,7 +196,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
}
/**
* Category selection.
* Output category widget.
*/
public function category_widget() {

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Sales_By_Date
*
@ -9,12 +14,23 @@
*/
class WC_Report_Sales_By_Date extends WC_Admin_Report {
/**
* Chart colours.
*
* @var array
*/
public $chart_colours = array();
/**
* The report data.
*
* @var stdClass
*/
private $report_data;
/**
* Get report data.
* @return array
* @return stdClass
*/
public function get_report_data() {
if ( empty( $this->report_data ) ) {

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Sales_By_Product
*
@ -9,8 +14,25 @@
*/
class WC_Report_Sales_By_Product extends WC_Admin_Report {
/**
* Chart colours.
*
* @var array
*/
public $chart_colours = array();
/**
* Product ids.
*
* @var array
*/
public $product_ids = array();
/**
* Product ids with titles.
*
* @var array
*/
public $product_ids_titles = array();
/**
@ -124,7 +146,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
}
/**
* [get_chart_widgets description].
* Get chart widgets.
*
* @return array
*/
@ -148,7 +170,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
}
/**
* Show current filters.
* Output current filters.
*/
public function current_filters() {
@ -170,7 +192,7 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
}
/**
* Product selection.
* Output products widget.
*/
public function products_widget() {
?>

View File

@ -18,10 +18,15 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
*/
class WC_Report_Stock extends WP_List_Table {
/**
* Max items.
*
* @var int
*/
protected $max_items;
/**
* __construct function.
* Constructor.
*/
public function __construct() {
@ -41,6 +46,8 @@ class WC_Report_Stock extends WP_List_Table {
/**
* Don't need this.
*
* @param string $position
*/
public function display_tablenav( $position ) {
@ -61,10 +68,10 @@ class WC_Report_Stock extends WP_List_Table {
}
/**
* column_default function.
* Get column value.
*
* @param mixed $item
* @param mixed $column_name
* @param string $column_name
*/
public function column_default( $item, $column_name ) {
global $product;
@ -147,7 +154,9 @@ class WC_Report_Stock extends WP_List_Table {
}
/**
* get_columns function.
* Get columns.
*
* @return array
*/
public function get_columns() {
@ -163,7 +172,7 @@ class WC_Report_Stock extends WP_List_Table {
}
/**
* prepare_items function.
* Prepare customer list items.
*/
public function prepare_items() {

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Taxes_By_Code
*

View File

@ -1,4 +1,9 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* WC_Report_Taxes_By_Date
*

View File

@ -113,7 +113,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
'desc_tip' => __( 'Force SSL (HTTPS) on the checkout pages (an SSL Certificate is required).', 'woocommerce' ),
),
array(
'unforce_ssl_checkout' => array(
'desc' => __( 'Force HTTP when leaving the checkout', 'woocommerce' ),
'id' => 'woocommerce_unforce_ssl_checkout',
'default' => 'no',
@ -225,6 +225,10 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
) );
if ( wc_site_is_https() ) {
unset( $settings['unforce_ssl_checkout'] );
}
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
}

View File

@ -19,7 +19,18 @@ if ( ! class_exists( 'WC_Settings_Page' ) ) :
*/
abstract class WC_Settings_Page {
protected $id = '';
/**
* Setting page id.
*
* @var string
*/
protected $id = '';
/**
* Setting page label.
*
* @var string
*/
protected $label = '';
/**

View File

@ -19,6 +19,11 @@ if ( ! class_exists( 'WC_Settings_Tax' ) ) :
*/
class WC_Settings_Tax extends WC_Settings_Page {
/**
* Setting page id.
*
* @var string
*/
protected $id = 'tax';
/**

View File

@ -160,6 +160,7 @@ function woocommerce_update_options( $options ) {
* Get a setting from the settings API.
*
* @param mixed $option_name
* @param mixed $default
* @return string
*/
function woocommerce_settings_get_option( $option_name, $default = '' ) {

View File

@ -1545,7 +1545,7 @@ class WC_API_Products extends WC_API_Resource {
// Backorders.
if ( isset( $data['backorders'] ) ) {
if ( 'notify' == $data['backorders'] ) {
if ( 'notify' === $data['backorders'] ) {
$backorders = 'notify';
} else {
$backorders = ( true === $data['backorders'] ) ? 'yes' : 'no';

View File

@ -460,7 +460,7 @@ class WC_API_Server {
'tax_included' => wc_prices_include_tax(),
'weight_unit' => get_option( 'woocommerce_weight_unit' ),
'dimension_unit' => get_option( 'woocommerce_dimension_unit' ),
'ssl_enabled' => ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) ),
'ssl_enabled' => ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) || wc_site_is_https() ),
'permalinks_enabled' => ( '' !== get_option( 'permalink_structure' ) ),
'generate_password' => ( 'yes' === get_option( 'woocommerce_registration_generate_password' ) ),
'links' => array(

View File

@ -1835,7 +1835,7 @@ class WC_AJAX {
}
/**
* Search for gruoped products and return json.
* Search for grouped products and return json.
*/
public static function json_search_grouped_products() {
ob_start();

View File

@ -18,15 +18,26 @@ if ( ! class_exists( 'WC_API' ) ) :
class WC_API {
/** This is the major version for the REST API and takes
/**
* This is the major version for the REST API and takes
* first-order position in endpoint URLs.
*
* @var string
*/
const VERSION = '3.1.0';
/** @var WC_API_Server the REST API server */
/**
* The REST API server.
*
* @var WC_API_Server
*/
public $server;
/** @var WC_API_Authentication REST API authentication class instance */
/**
* REST API authentication class instance.
*
* @var WC_API_Authentication
*/
public $authentication;
/**
@ -56,7 +67,7 @@ class WC_API {
* Add new query vars.
*
* @since 2.0
* @param $vars
* @param array $vars
* @return string[]
*/
public function add_query_vars( $vars ) {

View File

@ -20,6 +20,8 @@ class WC_Auth {
/**
* Version.
*
* @var int
*/
const VERSION = 1;
@ -44,7 +46,7 @@ class WC_Auth {
*
* @since 2.4.0
*
* @param $vars
* @param array $vars
*
* @return string[]
*/

View File

@ -94,25 +94,53 @@ class WC_Cart {
'fees' => array()
);
/** @var array An array of fees. */
public $fees = array();
/**
* An array of fees.
*
* @var array
*/
public $fees = array();
/** @var boolean Prices inc tax */
/**
* Prices include tax.
*
* @var bool
*/
public $prices_include_tax;
/** @var boolean */
/**
* Round at subtotal.
*
* @var bool
*/
public $round_at_subtotal;
/** @var string */
/**
* Tax display cart.
*
* @var string
*/
public $tax_display_cart;
/** @var int Prices inc tax */
/**
* Prices inc tax.
*
* @var int
*/
public $dp;
/** @var boolean */
/**
* Display totals excluding tax.
*
* @var bool
*/
public $display_totals_ex_tax;
/** @var boolean */
/**
* Display cart excluding tax.
*
* @var bool
*/
public $display_cart_ex_tax;
/**
@ -449,18 +477,18 @@ class WC_Cart {
* @return bool|WP_Error
*/
public function check_cart_item_validity() {
foreach ( $this->get_cart() as $cart_item_key => $values ) {
$return = true;
foreach ( $this->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];
if ( ! $_product || ! $_product->exists() || $_product->post->post_status == 'trash' ) {
if ( ! $_product || ! $_product->exists() || 'trash' === $_product->post->post_status ) {
$this->set_quantity( $cart_item_key, 0 );
return new WP_Error( 'invalid', __( 'An item which is no longer available was removed from your cart.', 'woocommerce' ) );
$return = new WP_Error( 'invalid', __( 'An item which is no longer available was removed from your cart.', 'woocommerce' ) );
}
}
return true;
return $return;
}
/**
@ -859,9 +887,9 @@ class WC_Cart {
/**
* Add a product to the cart.
*
* @param integer $product_id contains the id of the product to add to the cart
* @param integer $quantity contains the quantity of the item to add
* @param integer $variation_id
* @param int $product_id contains the id of the product to add to the cart
* @param int $quantity contains the quantity of the item to add
* @param int $variation_id
* @param array $variation attribute values
* @param array $cart_item_data extra cart item data we want to pass into the item
* @return string $cart_item_key
@ -1029,9 +1057,9 @@ class WC_Cart {
/**
* Set the quantity for an item in the cart.
*
* @param string cart_item_key contains the id of the cart item
* @param string quantity contains the quantity of the item
* @param boolean $refresh_totals whether or not to calculate totals after setting the new qty
* @param string $cart_item_key contains the id of the cart item
* @param string $quantity contains the quantity of the item
* @param bool $refresh_totals whether or not to calculate totals after setting the new qty
*
* @return bool
*/
@ -1382,7 +1410,7 @@ class WC_Cart {
}
/**
* remove_taxes function.
* Remove taxes.
*/
public function remove_taxes() {
$this->shipping_tax_total = $this->tax_total = 0;
@ -1402,7 +1430,7 @@ class WC_Cart {
}
/**
* looks at the totals to see if payment is actually required.
* Looks at the totals to see if payment is actually required.
*
* @return bool
*/
@ -1902,7 +1930,7 @@ class WC_Cart {
*
* @access private
* @param string $code
* @param integer $count
* @param int $count
*/
private function increase_coupon_applied_count( $code, $count = 1 ) {
if ( empty( $this->coupon_applied_count[ $code ] ) ) {
@ -1946,7 +1974,7 @@ class WC_Cart {
}
/**
* get_fees function.
* Get fees.
*
* @return array
*/
@ -2171,8 +2199,8 @@ class WC_Cart {
/**
* Get tax row amounts with or without compound taxes includes.
*
* @param boolean $compound True if getting compound taxes
* @param boolean $display True if getting total to display
* @param bool $compound True if getting compound taxes
* @param bool $display True if getting total to display
* @return float price
*/
public function get_taxes_total( $compound = true, $display = true ) {
@ -2243,7 +2271,7 @@ class WC_Cart {
* Get the total of all order discounts (after tax discounts).
*
* @deprecated Order discounts (after tax) removed in 2.3
* @return integer
* @return int
*/
public function get_order_discount_total() {
_deprecated_function( 'get_order_discount_total', '2.3' );

View File

@ -155,17 +155,15 @@ class WC_Checkout {
}
/**
* Create an order.
*
* Error codes:
* 400 - Cannot insert order into the database.
* 401 - Cannote update existing order.
* 402 - Cannot create line item.
* 403 - Cannot create fee item.
* 404 - Cannot create shipping item.
* 405 - Cannot create tax item.
* 406 - Cannot create coupon item.
*
* Create an order. Error codes:
* 520 - Cannot insert order into the database.
* 521 - Cannot get order after creation.
* 522 - Cannot update order.
* 525 - Cannot create line item.
* 526 - Cannot create fee item.
* 527 - Cannot create shipping item.
* 528 - Cannot create tax item.
* 529 - Cannot create coupon item.
* @access public
* @throws Exception
* @return int|WP_ERROR
@ -199,7 +197,7 @@ class WC_Checkout {
$order = wc_update_order( $order_data );
if ( is_wp_error( $order ) ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 401 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 522 ) );
} else {
$order->remove_order_items();
do_action( 'woocommerce_resume_order', $order_id );
@ -210,7 +208,9 @@ class WC_Checkout {
$order = wc_create_order( $order_data );
if ( is_wp_error( $order ) ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 400 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 520 ) );
} elseif ( false === $order ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 521 ) );
} else {
$order_id = $order->id;
do_action( 'woocommerce_new_order', $order_id );
@ -235,7 +235,7 @@ class WC_Checkout {
);
if ( ! $item_id ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 402 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 525 ) );
}
// Allow plugins to add order item meta
@ -247,7 +247,7 @@ class WC_Checkout {
$item_id = $order->add_fee( $fee );
if ( ! $item_id ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 403 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 526 ) );
}
// Allow plugins to add order item meta to fees
@ -260,7 +260,7 @@ class WC_Checkout {
$item_id = $order->add_shipping( $package['rates'][ $this->shipping_methods[ $package_key ] ] );
if ( ! $item_id ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 404 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 527 ) );
}
// Allows plugins to add order item meta to shipping
@ -271,14 +271,14 @@ class WC_Checkout {
// Store tax rows
foreach ( array_keys( WC()->cart->taxes + WC()->cart->shipping_taxes ) as $tax_rate_id ) {
if ( $tax_rate_id && ! $order->add_tax( $tax_rate_id, WC()->cart->get_tax_amount( $tax_rate_id ), WC()->cart->get_shipping_tax_amount( $tax_rate_id ) ) && apply_filters( 'woocommerce_cart_remove_taxes_zero_rate_id', 'zero-rated' ) !== $tax_rate_id ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 405 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 528 ) );
}
}
// Store coupons
foreach ( WC()->cart->get_coupons() as $code => $coupon ) {
if ( ! $order->add_coupon( $code, WC()->cart->get_coupon_discount_amount( $code ), WC()->cart->get_coupon_discount_tax_amount( $code ) ) ) {
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 406 ) );
throw new Exception( sprintf( __( 'Error %d: Unable to create order. Please try again.', 'woocommerce' ), 529 ) );
}
}

View File

@ -213,6 +213,8 @@ class WC_Comments {
/**
* Modify recipient of review email.
* @param array $emails
* @param int $comment_id
* @return array
*/
public static function comment_moderation_recipients( $emails, $comment_id ) {

View File

@ -223,7 +223,7 @@ class WC_Countries {
}
/**
* get_allowed_country_states function.
* Get allowed country states.
* @return array
*/
public function get_allowed_country_states() {
@ -245,7 +245,7 @@ class WC_Countries {
}
/**
* get_shipping_country_states function.
* Get shipping country states.
* @return array
*/
public function get_shipping_country_states() {
@ -345,6 +345,7 @@ class WC_Countries {
* Outputs the list of countries and states for use in dropdown boxes.
* @param string $selected_country (default: '')
* @param string $selected_state (default: '')
* @param bool $escape (default: false)
* @param bool $escape (default: false)
*/
public function country_dropdown_options( $selected_country = '', $selected_state = '', $escape = false ) {
@ -504,7 +505,7 @@ class WC_Countries {
/**
* Trim white space and commas off a line.
* @param string
* @param string $line
* @return string
*/
private function trim_formatted_address_line( $line ) {
@ -551,7 +552,6 @@ class WC_Countries {
),
'city' => array(
'label' => __( 'Town / City', 'woocommerce' ),
'placeholder' => __( 'Town / City', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field' )
),
@ -564,7 +564,6 @@ class WC_Countries {
),
'postcode' => array(
'label' => __( 'Postcode / ZIP', 'woocommerce' ),
'placeholder' => __( 'Postcode / ZIP', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last', 'address-field' ),
'clear' => true,
@ -620,15 +619,12 @@ class WC_Countries {
'AU' => array(
'city' => array(
'label' => __( 'Suburb', 'woocommerce' ),
'placeholder' => __( 'Suburb', 'woocommerce' ),
),
'postcode' => array(
'label' => __( 'Postcode', 'woocommerce' ),
'placeholder' => __( 'Postcode', 'woocommerce' ),
),
'state' => array(
'label' => __( 'State', 'woocommerce' ),
//'placeholder' => __( 'State', 'woocommerce' ),
)
),
'AX' => array(
@ -643,7 +639,6 @@ class WC_Countries {
),
'state' => array(
'label' => __( 'District', 'woocommerce' ),
//'placeholder' => __( 'District', 'woocommerce' ),
)
),
'BE' => array(
@ -651,7 +646,6 @@ class WC_Countries {
'state' => array(
'required' => false,
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
),
),
'BI' => array(
@ -674,14 +668,12 @@ class WC_Countries {
'CA' => array(
'state' => array(
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'CH' => array(
'postcode_before_city' => true,
'state' => array(
'label' => __( 'Canton', 'woocommerce' ),
//'placeholder' => __( 'Canton', 'woocommerce' ),
'required' => false
)
),
@ -694,13 +686,11 @@ class WC_Countries {
),
'state' => array(
'label' => __( 'Region', 'woocommerce' ),
//'placeholder' => __( 'Region', 'woocommerce' )
)
),
'CN' => array(
'state' => array(
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'CO' => array(
@ -749,23 +739,19 @@ class WC_Countries {
),
'city' => array(
'label' => __( 'Town / District', 'woocommerce' ),
'placeholder' => __( 'Town / District', 'woocommerce' )
),
'state' => array(
'label' => __( 'Region', 'woocommerce' ),
//'placeholder' => __( 'Region', 'woocommerce' ),
)
),
'HU' => array(
'state' => array(
'label' => __( 'County', 'woocommerce' ),
//'placeholder' => __( 'County', 'woocommerce' ),
)
),
'ID' => array(
'state' => array(
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'IS' => array(
@ -785,7 +771,6 @@ class WC_Countries {
'state' => array(
'required' => true,
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'JP' => array(
@ -803,7 +788,6 @@ class WC_Countries {
'state' => array(
'required' => false,
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'NZ' => array(
@ -820,7 +804,6 @@ class WC_Countries {
'NP' => array(
'state' => array(
'label' => __( 'State / Zone', 'woocommerce' ),
//'placeholder' => __( 'State / Zone', 'woocommerce' ),
),
'postcode' => array(
'required' => false
@ -863,14 +846,12 @@ class WC_Countries {
'postcode_before_city' => true,
'state' => array(
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'LI' => array(
'postcode_before_city' => true,
'state' => array(
'label' => __( 'Municipality', 'woocommerce' ),
//'placeholder' => __( 'Municipality', 'woocommerce' ),
'required' => false
)
),
@ -889,27 +870,22 @@ class WC_Countries {
'postcode_before_city' => true,
'state' => array(
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'US' => array(
'postcode' => array(
'label' => __( 'ZIP', 'woocommerce' ),
'placeholder' => __( 'ZIP', 'woocommerce' ),
),
'state' => array(
'label' => __( 'State', 'woocommerce' ),
//'placeholder' => __( 'State', 'woocommerce' ),
)
),
'GB' => array(
'postcode' => array(
'label' => __( 'Postcode', 'woocommerce' ),
'placeholder' => __( 'Postcode', 'woocommerce' ),
),
'state' => array(
'label' => __( 'County', 'woocommerce' ),
//'placeholder' => __( 'County', 'woocommerce' ),
'required' => false
)
),
@ -936,7 +912,6 @@ class WC_Countries {
'ZA' => array(
'state' => array(
'label' => __( 'Province', 'woocommerce' ),
//'placeholder' => __( 'Province', 'woocommerce' ),
)
),
'ZW' => array(
@ -967,7 +942,7 @@ class WC_Countries {
/**
* Apply locale and get address fields.
* @param mixed $country
* @param mixed $country (default: '')
* @param string $type (default: 'billing_')
* @return array
*/

View File

@ -331,6 +331,8 @@ class WC_Coupon {
/**
* Ensure coupon exists or throw exception.
*
* @throws Exception
*/
private function validate_exists() {
if ( ! $this->exists ) {
@ -340,6 +342,8 @@ class WC_Coupon {
/**
* Ensure coupon usage limit is valid or throw exception.
*
* @throws Exception
*/
private function validate_usage_limit() {
if ( $this->usage_limit > 0 && $this->usage_count >= $this->usage_limit ) {
@ -376,6 +380,8 @@ class WC_Coupon {
/**
* Ensure coupon date is valid or throw exception.
*
* @throws Exception
*/
private function validate_expiry_date() {
if ( $this->expiry_date && current_time( 'timestamp' ) > $this->expiry_date ) {
@ -385,6 +391,8 @@ class WC_Coupon {
/**
* Ensure coupon amount is valid or throw exception.
*
* @throws Exception
*/
private function validate_minimum_amount() {
if ( $this->minimum_amount > 0 && wc_format_decimal( $this->minimum_amount ) > wc_format_decimal( WC()->cart->subtotal ) ) {
@ -394,6 +402,8 @@ class WC_Coupon {
/**
* Ensure coupon amount is valid or throw exception.
*
* @throws Exception
*/
private function validate_maximum_amount() {
if ( $this->maximum_amount > 0 && wc_format_decimal( $this->maximum_amount ) < wc_format_decimal( WC()->cart->subtotal ) ) {
@ -403,6 +413,8 @@ class WC_Coupon {
/**
* Ensure coupon is valid for products in the cart is valid or throw exception.
*
* @throws Exception
*/
private function validate_product_ids() {
if ( sizeof( $this->product_ids ) > 0 ) {
@ -422,6 +434,8 @@ class WC_Coupon {
/**
* Ensure coupon is valid for product categories in the cart is valid or throw exception.
*
* @throws Exception
*/
private function validate_product_categories() {
if ( sizeof( $this->product_categories ) > 0 ) {
@ -443,6 +457,8 @@ class WC_Coupon {
/**
* Ensure coupon is valid for sale items in the cart is valid or throw exception.
*
* @throws Exception
*/
private function validate_sale_items() {
if ( 'yes' === $this->exclude_sale_items && $this->is_type( wc_get_product_coupon_types() ) ) {
@ -479,6 +495,8 @@ class WC_Coupon {
/**
* Exclude products from cart.
*
* @throws Exception
*/
private function validate_cart_excluded_product_ids() {
// Exclude Products
@ -499,6 +517,8 @@ class WC_Coupon {
/**
* Exclude categories from cart.
*
* @throws Exception
*/
private function validate_cart_excluded_product_categories() {
if ( sizeof( $this->exclude_product_categories ) > 0 ) {
@ -521,6 +541,8 @@ class WC_Coupon {
/**
* Exclude sale items from cart.
*
* @throws Exception
*/
private function validate_cart_excluded_sale_items() {
if ( $this->exclude_sale_items == 'yes' ) {
@ -547,6 +569,7 @@ class WC_Coupon {
* Check if a coupon is valid.
*
* @return boolean validity
* @throws Exception
*/
public function is_valid() {
try {

View File

@ -142,7 +142,7 @@ class WC_Customer {
}
/**
* has_calculated_shipping function.
* Has calculated shipping?
*
* @return bool
*/
@ -322,7 +322,7 @@ class WC_Customer {
}
/**
* get_taxable_address function.
* Get taxable address.
*
* @return array
*/
@ -550,7 +550,7 @@ class WC_Customer {
}
/**
* calculated_shipping function.
* Calculated shipping.
*
* @param boolean $calculated
*/

View File

@ -275,16 +275,7 @@ class WC_Emails {
* @return string
*/
public function order_meta( $order, $sent_to_admin = false, $plain_text = false ) {
$fields = array();
if ( $order->customer_note ) {
$fields['customer_note'] = array(
'label' => __( 'Note', 'woocommerce' ),
'value' => wptexturize( $order->customer_note )
);
}
$fields = apply_filters( 'woocommerce_email_order_meta_fields', $fields, $sent_to_admin, $order );
$fields = apply_filters( 'woocommerce_email_order_meta_fields', array(), $sent_to_admin, $order );
/**
* Deprecated woocommerce_email_order_meta_keys filter.
@ -347,6 +338,13 @@ class WC_Emails {
public function customer_details( $order, $sent_to_admin = false, $plain_text = false ) {
$fields = array();
if ( $order->customer_note ) {
$fields['customer_note'] = array(
'label' => __( 'Note', 'woocommerce' ),
'value' => wptexturize( $order->customer_note )
);
}
if ( $order->billing_email ) {
$fields['billing_email'] = array(
'label' => __( 'Email', 'woocommerce' ),

View File

@ -15,7 +15,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
/**
* WC_Geolocation Class.
* WC_Geo_IP Class.
*/
class WC_Geo_IP {
@ -54,20 +54,60 @@ class WC_Geo_IP {
const GEOIP_ORG_EDITION_V6 = 23;
const GEOIP_DOMAIN_EDITION_V6 = 24;
/**
* Flags.
*
* @var array
*/
public $flags;
/**
* File handler.
*
* @var resource
*/
public $filehandle;
/**
* Memory buffer.
*
* @var array
*/
public $memory_buffer;
/**
* Database type.
*
* @var string
*/
public $databaseType;
/**
* Database segments.
*
* @var int
*/
public $databaseSegments;
/**
* Record length.
*
* @var int
*/
public $record_length;
/**
* Shmid.
*
* @var string
*/
public $shmid;
/**
* Two letters country codes.
*
* @var array
*/
public $GEOIP_COUNTRY_CODES = array(
'',
'AP',
@ -327,6 +367,11 @@ class WC_Geo_IP {
'O1'
);
/**
* 3 letters country codes.
*
* @var array
*/
public $GEOIP_COUNTRY_CODES3 = array(
'',
'AP',
@ -586,6 +631,11 @@ class WC_Geo_IP {
'O1'
);
/**
* Contry names.
*
* @var array
*/
public $GEOIP_COUNTRY_NAMES = array(
'',
'Asia/Pacific Region',
@ -845,6 +895,11 @@ class WC_Geo_IP {
'Other'
);
/**
* 2 letters continent codes.
*
* @var array
*/
public $GEOIP_CONTINENT_CODES = array(
'--',
'AS',
@ -1667,16 +1722,91 @@ class WC_Geo_IP {
* Geo IP Record class.
*/
class WC_Geo_IP_Record {
/**
* Country code.
*
* @var string
*/
public $country_code;
/**
* 3 letters country code.
*
* @var string
*/
public $country_code3;
/**
* Country name.
*
* @var string
*/
public $country_name;
/**
* Region.
*
* @var string
*/
public $region;
/**
* City.
*
* @var string
*/
public $city;
/**
* Postal code.
*
* @var string
*/
public $postal_code;
/**
* Latitude
*
* @var float
*/
public $latitude;
/**
* Longitude.
*
* @var float
*/
public $longitude;
/**
* Area code.
*
* @var string
*/
public $area_code;
public $dma_code; // metro and dma code are the same. use metro_code
/**
* DMA Code.
*
* Metro and DMA code are the same.
* Use metro code instead.
*
* @var int
*/
public $dma_code;
/**
* Metro code.
*
* @var int
*/
public $metro_code;
/**
* Continent code.
*
* @var string
*/
public $continent_code;
}

View File

@ -19,7 +19,7 @@ class WC_HTTPS {
* Hook in our HTTPS functions if we're on the frontend. This will ensure any links output to a page (when viewing via HTTPS) are also served over HTTPS.
*/
public static function init() {
if ( 'yes' == get_option( 'woocommerce_force_ssl_checkout' ) && ! is_admin() ) {
if ( 'yes' === get_option( 'woocommerce_force_ssl_checkout' ) && ! is_admin() ) {
// HTTPS urls with SSL on
$filters = array(
'post_thumbnail_html',
@ -48,7 +48,7 @@ class WC_HTTPS {
}
/**
* force_https_url function.
* Force https for urls.
*
* @param mixed $content
* @return string
@ -72,7 +72,7 @@ class WC_HTTPS {
public static function force_https_page_link( $link, $page_id ) {
if ( in_array( $page_id, array( get_option( 'woocommerce_checkout_page_id' ), get_option( 'woocommerce_myaccount_page_id' ) ) ) ) {
$link = str_replace( 'http:', 'https:', $link );
} elseif ( 'yes' == get_option( 'woocommerce_unforce_ssl_checkout' ) ) {
} elseif ( 'yes' === get_option( 'woocommerce_unforce_ssl_checkout' ) && ! wc_site_is_https() ) {
$link = str_replace( 'https:', 'http:', $link );
}
return $link;
@ -102,7 +102,7 @@ class WC_HTTPS {
return;
}
if ( is_ssl() && $_SERVER['REQUEST_URI'] && ! is_checkout() && ! is_ajax() && ! is_account_page() && apply_filters( 'woocommerce_unforce_ssl_checkout', true ) ) {
if ( ! wc_site_is_https() && is_ssl() && $_SERVER['REQUEST_URI'] && ! is_checkout() && ! is_ajax() && ! is_account_page() && apply_filters( 'woocommerce_unforce_ssl_checkout', true ) ) {
if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) {
wp_safe_redirect( preg_replace( '|^https://|', 'http://', $_SERVER['REQUEST_URI'] ) );

View File

@ -44,7 +44,7 @@ class WC_Install {
}
/**
* check_version function.
* Check WooCommerce version.
*/
public static function check_version() {
if ( ! defined( 'IFRAME_REQUEST' ) && ( get_option( 'woocommerce_version' ) != WC()->version ) ) {
@ -259,6 +259,8 @@ class WC_Install {
foreach ( $pages as $key => $page ) {
wc_create_page( esc_sql( $page['name'] ), 'woocommerce_' . $key . '_page_id', $page['title'], $page['content'], ! empty( $page['parent'] ) ? wc_get_page_id( $page['parent'] ) : '' );
}
delete_transient( 'woocommerce_cache_excluded_uris' );
}
/**

View File

@ -17,7 +17,11 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Integrations {
/** Array of integration classes */
/**
* Array of integrations.
*
* @var array
*/
public $integrations = array();
/**

View File

@ -16,7 +16,9 @@ if ( ! defined( 'ABSPATH' ) ) {
class WC_Logger {
/**
* @var array Stores open file _handles.
* Stores open file _handles.
*
* @var array
* @access private
*/
private $_handles;

View File

@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class WC_Order_Factory {
/**
* get_order function.
* Get order.
*
* @param bool $the_order (default: false)
* @return WC_Order|bool

View File

@ -17,6 +17,11 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Post_Data {
/**
* Editing term.
*
* @var object
*/
private static $editing_term = null;
/**

View File

@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class WC_Product_External extends WC_Product {
/**
* __construct function.
* Constructor.
*
* @access public
* @param mixed $product
@ -69,7 +69,7 @@ class WC_Product_External extends WC_Product {
}
/**
* get_product_url function.
* Get product url.
*
* @access public
* @return string
@ -79,7 +79,7 @@ class WC_Product_External extends WC_Product {
}
/**
* get_button_text function.
* Get button text.
*
* @access public
* @return string

View File

@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
class WC_Product_Factory {
/**
* get_product function.
* Get product.
*
* @param bool $the_product (default: false)
* @param array $args (default: array())

View File

@ -21,7 +21,7 @@ class WC_Product_Grouped extends WC_Product {
public $children;
/**
* __construct function.
* Constructor.
*
* @access public
* @param mixed $product

View File

@ -148,7 +148,7 @@ class WC_Product_Variable extends WC_Product {
}
/**
* get_child function.
* Get child product.
*
* @access public
* @param mixed $child_id

View File

@ -471,7 +471,9 @@ class WC_Product_Variation extends WC_Product {
}
/**
* set_stock_status function.
* Set stock status.
*
* @param string $status
*/
public function set_stock_status( $status ) {
$status = 'outofstock' === $status ? 'outofstock' : 'instock';
@ -588,7 +590,7 @@ class WC_Product_Variation extends WC_Product {
}
/**
* is_on_backorder function.
* Is on backorder?
*
* @param int $qty_in_cart (default: 0)
* @return bool

View File

@ -144,7 +144,7 @@ class WC_Query {
}
/**
* add_query_vars function.
* Add query vars.
*
* @access public
* @param array $vars
@ -308,7 +308,7 @@ class WC_Query {
}
/**
* search_post_excerpt function.
* Search post excerpt.
*
* @access public
* @param string $where (default: '')
@ -329,7 +329,8 @@ class WC_Query {
}
/**
* wpseo_metadesc function.
* WP SEO meta description.
*
* Hooked into wpseo_ hook already, so no need for function_exist.
*
* @access public
@ -340,7 +341,8 @@ class WC_Query {
}
/**
* wpseo_metakey function.
* WP SEO meta key.
*
* Hooked into wpseo_ hook already, so no need for function_exist.
*
* @access public
@ -605,7 +607,7 @@ class WC_Query {
}
/**
* order_by_rating_post_clauses function.
* Order by rating post clauses.
*
* @access public
* @param array $args

View File

@ -66,7 +66,6 @@ class WC_Session_Handler extends WC_Session {
add_action( 'shutdown', array( $this, 'save_data' ), 20 );
add_action( 'wp_logout', array( $this, 'destroy_session' ) );
if ( ! is_user_logged_in() ) {
add_action( 'woocommerce_thankyou', array( $this, 'destroy_session' ) );
add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
}
}

View File

@ -57,7 +57,7 @@ class WC_Shipping_Rate {
}
/**
* get_shipping_tax function.
* Get shipping tax.
*
* @return array
*/

View File

@ -90,7 +90,7 @@ class WC_Shipping {
}
/**
* init function.
* Initialize shipping.
*/
public function init() {
do_action( 'woocommerce_shipping_init' );
@ -122,7 +122,7 @@ class WC_Shipping {
}
/**
* Load shipping methods.
* Loads all shipping methods which are hooked in. If a $package is passed some methods may add themselves conditionally.
*
* Loads all shipping methods which are hooked in.
* If a $package is passed some methods may add themselves conditionally and zones will be used.
@ -173,7 +173,50 @@ class WC_Shipping {
}
/**
<<<<<<< HEAD
* Returns all registered shipping methods.
=======
* Sort shipping methods.
*
* Sorts shipping methods into the user defined order.
*
* @return array
*/
public function sort_shipping_methods() {
$sorted_shipping_methods = array();
// Get order option
$ordering = (array) get_option('woocommerce_shipping_method_order');
$order_end = 999;
// Load shipping methods in order
foreach ( $this->shipping_methods as $method ) {
if ( isset( $ordering[ $method->id ] ) && is_numeric( $ordering[ $method->id ] ) ) {
// Add in position
$sorted_shipping_methods[ $ordering[ $method->id ] ][] = $method;
} else {
// Add to end of the array
$sorted_shipping_methods[ $order_end ][] = $method;
}
}
ksort( $sorted_shipping_methods );
$this->shipping_methods = array();
foreach ( $sorted_shipping_methods as $methods )
foreach ( $methods as $method ) {
$id = empty( $method->instance_id ) ? $method->id : $method->instance_id;
$this->shipping_methods[ $id ] = $method;
}
return $this->shipping_methods;
}
/**
* Returns all registered shipping methods for usage.
*
* @access public
* @return array

View File

@ -446,9 +446,9 @@ class WC_Shortcodes {
return '';
}
$product = wc_setup_product_data( $product_data );
if ( ! $product ) {
if ( is_object( $product_data ) ) {
$product = wc_setup_product_data( $product_data );
} else {
return '';
}
@ -494,6 +494,12 @@ class WC_Shortcodes {
return '';
}
if ( is_object( $product_data ) ) {
$product = wc_setup_product_data( $product_data );
} else {
return '';
}
if ( 'product' !== $product_data->post_type ) {
return '';
}

View File

@ -15,7 +15,18 @@ if ( ! defined( 'ABSPATH' ) ) {
*/
class WC_Tax {
/**
* Precision.
*
* @var int
*/
public static $precision;
/**
* Round at subtotal.
*
* @var bool
*/
public static $round_at_subtotal;
/**

View File

@ -84,7 +84,7 @@ class WC_Template_Loader {
}
/**
* comments_template_loader function.
* Load comments template.
*
* @param mixed $template
* @return string

View File

@ -44,6 +44,8 @@ class WC_Email_Cancelled_Order extends WC_Email {
/**
* Trigger.
*
* @param int $order_id
*/
public function trigger( $order_id ) {
if ( $order_id ) {
@ -62,7 +64,7 @@ class WC_Email_Cancelled_Order extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string

View File

@ -48,6 +48,8 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
/**
* Trigger.
*
* @param int $order_id
*/
function trigger( $order_id ) {
@ -70,7 +72,7 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
}
/**
* get_subject function.
* Get email subject.
*
* @access public
* @return string
@ -84,7 +86,7 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
}
/**
* get_heading function.
* Get email heading.
*
* @access public
* @return string
@ -98,7 +100,7 @@ class WC_Email_Customer_Completed_Order extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string

View File

@ -19,7 +19,18 @@ if ( ! class_exists( 'WC_Email_Customer_Invoice' ) ) :
*/
class WC_Email_Customer_Invoice extends WC_Email {
/**
* Strings to find in subjects/headings.
*
* @var array
*/
public $find;
/**
* Strings to replace in subjects/headings.
*
* @var array
*/
public $replace;
/**
@ -51,6 +62,8 @@ class WC_Email_Customer_Invoice extends WC_Email {
/**
* Trigger.
*
* @param int|WC_Order $order
*/
function trigger( $order ) {
@ -77,7 +90,7 @@ class WC_Email_Customer_Invoice extends WC_Email {
}
/**
* get_subject function.
* Get email subject.
*
* @access public
* @return string
@ -91,7 +104,7 @@ class WC_Email_Customer_Invoice extends WC_Email {
}
/**
* get_heading function.
* Get email heading.
*
* @access public
* @return string
@ -105,7 +118,7 @@ class WC_Email_Customer_Invoice extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string
@ -121,7 +134,7 @@ class WC_Email_Customer_Invoice extends WC_Email {
}
/**
* get_content_plain function.
* Get content plain.
*
* @access public
* @return string

View File

@ -19,9 +19,32 @@ if ( ! class_exists( 'WC_Email_Customer_New_Account' ) ) :
*/
class WC_Email_Customer_New_Account extends WC_Email {
/**
* User login name.
*
* @var string
*/
public $user_login;
/**
* User email.
*
* @var string
*/
public $user_email;
/**
* User password.
*
* @var string
*/
public $user_pass;
/**
* Is the password generated?
*
* @var bool
*/
public $password_generated;
/**
@ -46,6 +69,10 @@ class WC_Email_Customer_New_Account extends WC_Email {
/**
* Trigger.
*
* @param int $user_id
* @param string $user_pass
* @param bool $password_generated
*/
function trigger( $user_id, $user_pass = '', $password_generated = false ) {
@ -67,7 +94,7 @@ class WC_Email_Customer_New_Account extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string
@ -86,7 +113,7 @@ class WC_Email_Customer_New_Account extends WC_Email {
}
/**
* get_content_plain function.
* Get content plain.
*
* @access public
* @return string

View File

@ -19,6 +19,11 @@ if ( ! class_exists( 'WC_Email_Customer_Note' ) ) :
*/
class WC_Email_Customer_Note extends WC_Email {
/**
* Customer note.
*
* @var string
*/
public $customer_note;
/**
@ -46,6 +51,8 @@ class WC_Email_Customer_Note extends WC_Email {
/**
* Trigger.
*
* @param array $args
*/
function trigger( $args ) {
@ -82,7 +89,7 @@ class WC_Email_Customer_Note extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string
@ -99,7 +106,7 @@ class WC_Email_Customer_Note extends WC_Email {
}
/**
* get_content_plain function.
* Get content plain.
*
* @access public
* @return string

View File

@ -42,6 +42,8 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
/**
* Trigger.
*
* @param int $order_id
*/
function trigger( $order_id ) {
@ -64,7 +66,7 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string
@ -80,7 +82,7 @@ class WC_Email_Customer_Processing_Order extends WC_Email {
}
/**
* get_content_plain function.
* Get content plain.
*
* @access public
* @return string

View File

@ -19,7 +19,18 @@ if ( ! class_exists( 'WC_Email_Customer_Refunded_Order' ) ) :
*/
class WC_Email_Customer_Refunded_Order extends WC_Email {
/**
* Refund order.
*
* @var WC_Order
*/
public $refund;
/**
* Is the order partial refunded?
*
* @var bool
*/
public $partial_refund;
/**
@ -37,6 +48,11 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
parent::__construct();
}
/**
* Set email strings.
*
* @param bool $partial_refund
*/
public function set_email_strings( $partial_refund = false ) {
$this->subject_partial = $this->get_option( 'subject_partial', __( 'Your {site_title} order from {order_date} has been partially refunded', 'woocommerce' ) );
$this->subject_full = $this->get_option( 'subject_full', __( 'Your {site_title} order from {order_date} has been refunded', 'woocommerce' ) );
@ -66,6 +82,9 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
/**
* Full refund notification.
*
* @param int $order_id
* @param int $refund_id
*/
public function trigger_full( $order_id, $refund_id = null ) {
$this->trigger( $order_id, false, $refund_id );
@ -73,6 +92,9 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
/**
* Partial refund notification.
*
* @param int $order_id
* @param int $refund_id
*/
public function trigger_partial( $order_id, $refund_id = null ) {
$this->trigger( $order_id, true, $refund_id );
@ -80,6 +102,10 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
/**
* Trigger.
*
* @param int $order_id
* @param bool $partial_refund
* @param int $refund_id
*/
public function trigger( $order_id, $partial_refund = false, $refund_id = null ) {
$this->partial_refund = $partial_refund;
@ -110,7 +136,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
}
/**
* get_subject function.
* Get email subject.
*
* @access public
* @return string
@ -120,7 +146,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
}
/**
* get_heading function.
* Get email heading.
*
* @access public
* @return string
@ -130,7 +156,7 @@ class WC_Email_Customer_Refunded_Order extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string

View File

@ -19,13 +19,25 @@ if ( ! class_exists( 'WC_Email_Customer_Reset_Password' ) ) :
*/
class WC_Email_Customer_Reset_Password extends WC_Email {
/** @var string */
/**
* User login name.
*
* @var string
*/
public $user_login;
/** @var string */
/**
* User email.
*
* @var string
*/
public $user_email;
/** @var string */
/**
* Reset key.
*
* @var string
*/
public $reset_key;
/**
@ -53,6 +65,9 @@ class WC_Email_Customer_Reset_Password extends WC_Email {
/**
* Trigger.
*
* @param string $user_login
* @param string $reset_key
*/
function trigger( $user_login = '', $reset_key = '' ) {
if ( $user_login && $reset_key ) {
@ -73,7 +88,7 @@ class WC_Email_Customer_Reset_Password extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string
@ -91,7 +106,7 @@ class WC_Email_Customer_Reset_Password extends WC_Email {
}
/**
* get_content_plain function.
* Get content plain.
*
* @access public
* @return string

View File

@ -44,6 +44,8 @@ class WC_Email_Failed_Order extends WC_Email {
/**
* Trigger.
*
* @param int $order_id
*/
public function trigger( $order_id ) {
if ( $order_id ) {
@ -62,7 +64,7 @@ class WC_Email_Failed_Order extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string

View File

@ -48,6 +48,8 @@ class WC_Email_New_Order extends WC_Email {
/**
* Trigger.
*
* @param int $order_id
*/
public function trigger( $order_id ) {
if ( $order_id ) {
@ -66,7 +68,7 @@ class WC_Email_New_Order extends WC_Email {
}
/**
* get_content_html function.
* Get content html.
*
* @access public
* @return string
@ -82,7 +84,7 @@ class WC_Email_New_Order extends WC_Email {
}
/**
* get_content_plain function.
* Get content plain.
*
* @access public
* @return string

View File

@ -220,7 +220,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* handle_multipart function.
* Handle multipart mail.
*
* @param PHPMailer $mailer
* @return PHPMailer
@ -234,7 +234,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* format_string function.
* Format email string.
*
* @param mixed $string
* @return string
@ -244,7 +244,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_subject function.
* Get email subject.
*
* @return string
*/
@ -253,7 +253,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_heading function.
* Get email heading.
*
* @return string
*/
@ -273,7 +273,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_headers function.
* Get email headers.
*
* @return string
*/
@ -282,7 +282,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_attachments function.
* Get email attachments.
*
* @return string|array
*/
@ -300,7 +300,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_content_type function.
* Get email content type.
*
* @return string
*/
@ -368,7 +368,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_blogname function.
* Get WordPress blog name.
*
* @return string
*/
@ -377,7 +377,7 @@ class WC_Email extends WC_Settings_API {
}
/**
* get_content function.
* Get email content.
*
* @return string
*/

View File

@ -105,7 +105,9 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
}
/**
* generate_account_details_html function.
* Generate account details html.
*
* @return string
*/
public function generate_account_details_html() {
@ -224,6 +226,8 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
/**
* Output for the order received page.
*
* @param int $order_id
*/
public function thankyou_page( $order_id ) {
@ -254,6 +258,8 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
/**
* Get bank details and place into a list format.
*
* @param int $order_id
*/
private function bank_details( $order_id = '' ) {
@ -350,7 +356,6 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
*
* @return array
*/
public function get_country_locale() {
if ( ! $this->locale ) {

View File

@ -1,9 +1,4 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* PayPal Standard Payment Gateway.
*
@ -15,9 +10,17 @@ if ( ! defined( 'ABSPATH' ) ) {
* @package WooCommerce/Classes/Payment
* @author WooThemes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WC_Gateway_Paypal Class.
*/
class WC_Gateway_Paypal extends WC_Payment_Gateway {
/** @var boolean Whether or not logging is enabled */
/** @var bool Whether or not logging is enabled */
public static $log_enabled = false;
/** @var WC_Logger Logger instance */
@ -41,7 +44,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
$this->init_form_fields();
$this->init_settings();
// Define user set variables
// Define user set variables.
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->testmode = 'yes' === $this->get_option( 'testmode', 'no' );
@ -69,7 +72,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
/**
* Logging method.
* @param string $message
* @param string $message
*/
public static function log( $message ) {
if ( self::$log_enabled ) {
@ -81,8 +84,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
}
/**
* get_icon function.
*
* Get gateway icon.
* @return string
*/
public function get_icon() {
@ -181,7 +183,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
/**
* Check if this gateway is enabled and available in the user's country.
*
* @return bool
*/
public function is_valid_for_use() {
@ -213,9 +214,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
/**
* Get the transaction URL.
*
* @param WC_Order $order
*
* @return string
*/
public function get_transaction_url( $order ) {
@ -229,8 +228,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
/**
* Process the payment and return the result.
*
* @param int $order_id
* @param int $order_id
* @return array
*/
public function process_payment( $order_id ) {
@ -256,10 +254,10 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
/**
* Process a refund if supported.
* @param int $order_id
* @param float $amount
* @param int $order_id
* @param float $amount
* @param string $reason
* @return boolean True or false based on success, or a WP_Error object
* @return bool True or false based on success, or a WP_Error object
*/
public function process_refund( $order_id, $amount = null, $reason = '' ) {
$order = wc_get_order( $order_id );

View File

@ -1,7 +1,7 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
include_once( 'class-wc-gateway-paypal-response.php' );
@ -16,6 +16,9 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Constructor.
*
* @param bool $sandbox
* @param string $receiver_email
*/
public function __construct( $sandbox = false, $receiver_email = '' ) {
add_action( 'woocommerce_api_wc_gateway_paypal', array( $this, 'check_response' ) );
@ -32,10 +35,11 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
if ( ! empty( $_POST ) && $this->validate_ipn() ) {
$posted = wp_unslash( $_POST );
do_action( "valid-paypal-standard-ipn-request", $posted );
do_action( 'valid-paypal-standard-ipn-request', $posted );
exit;
}
wp_die( "PayPal IPN Request Failure", "PayPal IPN", array( 'response' => 500 ) );
wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) );
}
/**
@ -45,10 +49,10 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
public function valid_response( $posted ) {
if ( ! empty( $posted['custom'] ) && ( $order = $this->get_paypal_order( $posted['custom'] ) ) ) {
// Lowercase returned variables
// Lowercase returned variables.
$posted['payment_status'] = strtolower( $posted['payment_status'] );
// Sandbox fix
// Sandbox fix.
if ( isset( $posted['test_ipn'] ) && 1 == $posted['test_ipn'] && 'pending' == $posted['payment_status'] ) {
$posted['payment_status'] = 'completed';
}
@ -82,13 +86,13 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
'user-agent' => 'WooCommerce/' . WC()->version
);
// Post back to get a response
// Post back to get a response.
$response = wp_safe_remote_post( $this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
WC_Gateway_Paypal::log( 'IPN Request: ' . print_r( $params, true ) );
WC_Gateway_Paypal::log( 'IPN Response: ' . print_r( $response, true ) );
// check to see if the request was valid
// Check to see if the request was valid.
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
WC_Gateway_Paypal::log( 'Received valid response from PayPal' );
return true;
@ -105,7 +109,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Check for a valid transaction type.
* @param string $txn_type
* @param string $txn_type
*/
protected function validate_transaction_type( $txn_type ) {
$accepted_types = array( 'cart', 'instant', 'express_checkout', 'web_accept', 'masspay', 'send_money' );
@ -118,15 +122,14 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Check currency from IPN matches the order.
* @param WC_Order $order
* @param string $currency
* @param WC_Order $order
* @param string $currency
*/
protected function validate_currency( $order, $currency ) {
// Validate currency
if ( $order->get_order_currency() != $currency ) {
WC_Gateway_Paypal::log( 'Payment error: Currencies do not match (sent "' . $order->get_order_currency() . '" | returned "' . $currency . '")' );
// Put this order on-hold for manual checking
// Put this order on-hold for manual checking.
$order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'woocommerce' ), $currency ) );
exit;
}
@ -134,13 +137,14 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Check payment amount from IPN matches the order.
* @param WC_Order $order
* @param WC_Order $order
* @param int $amount
*/
protected function validate_amount( $order, $amount ) {
if ( number_format( $order->get_total(), 2, '.', '' ) != number_format( $amount, 2, '.', '' ) ) {
WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (gross ' . $amount . ')' );
// Put this order on-hold for manual checking
// Put this order on-hold for manual checking.
$order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'woocommerce' ), $amount ) );
exit;
}
@ -149,22 +153,23 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Check receiver email from PayPal. If the receiver email in the IPN is different than what is stored in.
* WooCommerce -> Settings -> Checkout -> PayPal, it will log an error about it.
* @param WC_Order $order
* @param WC_Order $order
* @param string $receiver_email
*/
protected function validate_receiver_email( $order, $receiver_email ) {
if ( strcasecmp( trim( $receiver_email ), trim( $this->receiver_email ) ) != 0 ) {
WC_Gateway_Paypal::log( "IPN Response is for another account: {$receiver_email}. Your email is {$this->receiver_email}" );
// Put this order on-hold for manual checking
// Put this order on-hold for manual checking.
$order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'woocommerce' ), $receiver_email ) );
exit;
}
}
/**
* Handle a completed payment.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_completed( $order, $posted ) {
if ( $order->has_status( 'completed' ) ) {
@ -182,7 +187,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
$this->payment_complete( $order, ( ! empty( $posted['txn_id'] ) ? wc_clean( $posted['txn_id'] ) : '' ), __( 'IPN payment completed', 'woocommerce' ) );
if ( ! empty( $posted['mc_fee'] ) ) {
// log paypal transaction fee
// Log paypal transaction fee.
update_post_meta( $order->id, 'PayPal Transaction Fee', wc_clean( $posted['mc_fee'] ) );
}
@ -193,7 +198,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a pending payment.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_pending( $order, $posted ) {
$this->payment_status_completed( $order, $posted );
@ -201,7 +207,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a failed payment.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_failed( $order, $posted ) {
$order->update_status( 'failed', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), wc_clean( $posted['payment_status'] ) ) );
@ -209,7 +216,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a denied payment.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_denied( $order, $posted ) {
$this->payment_status_failed( $order, $posted );
@ -217,7 +225,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle an expired payment.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_expired( $order, $posted ) {
$this->payment_status_failed( $order, $posted );
@ -225,7 +234,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a voided payment.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_voided( $order, $posted ) {
$this->payment_status_failed( $order, $posted );
@ -233,13 +243,14 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a refunded order.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_refunded( $order, $posted ) {
// Only handle full refunds, not partial
// Only handle full refunds, not partial.
if ( $order->get_total() == ( $posted['mc_gross'] * -1 ) ) {
// Mark order as refunded
// Mark order as refunded.
$order->update_status( 'refunded', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), strtolower( $posted['payment_status'] ) ) );
$this->send_ipn_email_notification(
@ -251,7 +262,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a reveral.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_reversed( $order, $posted ) {
$order->update_status( 'on-hold', sprintf( __( 'Payment %s via IPN.', 'woocommerce' ), wc_clean( $posted['payment_status'] ) ) );
@ -264,7 +276,8 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Handle a cancelled reveral.
* @param WC_Order $order
* @param WC_Order $order
* @param array $posted
*/
protected function payment_status_canceled_reversal( $order, $posted ) {
$this->send_ipn_email_notification(
@ -276,6 +289,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Save important data from the IPN to the order.
* @param WC_Order $order
* @param array $posted
*/
protected function save_paypal_meta_data( $order, $posted ) {
if ( ! empty( $posted['payer_email'] ) ) {
@ -294,14 +308,14 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
/**
* Send a notification to the user handling orders.
* @param string $subject
* @param string $message
* @param string $subject
* @param string $message
*/
protected function send_ipn_email_notification( $subject, $message ) {
$new_order_settings = get_option( 'woocommerce_new_order_settings', array() );
$mailer = WC()->mailer();
$message = $mailer->wrap_message( $subject, $message );
$mailer->send( ! empty( $new_order_settings['recipient'] ) ? $new_order_settings['recipient'] : get_option( 'admin_email' ), $subject, $message );
$mailer->send( ! empty( $new_order_settings['recipient'] ) ? $new_order_settings['recipient'] : get_option( 'admin_email' ), strip_tags( $subject ), $message );
}
}

View File

@ -1,7 +1,7 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
include_once( 'class-wc-gateway-paypal-response.php' );
@ -16,6 +16,9 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
/**
* Constructor.
*
* @param bool $sandbox
* @param string $identity_token
*/
public function __construct( $sandbox = false, $identity_token = '' ) {
add_action( 'woocommerce_thankyou_paypal', array( $this, 'check_response' ) );
@ -41,7 +44,7 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
'user-agent' => 'WooCommerce/' . WC_VERSION
);
// Post back to get a response
// Post back to get a response.
$response = wp_safe_remote_post( $this->sandbox ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $pdt );
if ( is_wp_error( $response ) || ! strpos( $response['body'], "SUCCESS" ) === 0 ) {
@ -76,7 +79,7 @@ class WC_Gateway_Paypal_PDT_Handler extends WC_Gateway_Paypal_Response {
$this->payment_complete( $order, $transaction, __( 'PDT payment completed', 'woocommerce' ) );
if ( ! empty( $_REQUEST['mc_fee'] ) ) {
// log paypal transaction fee
// Log paypal transaction fee.
update_post_meta( $order->id, 'PayPal Transaction Fee', wc_clean( $_REQUEST['mc_fee'] ) );
}
}

View File

@ -1,11 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
/**
* Handles refunds.
* Handles Refunds.
*/
class WC_Gateway_Paypal_Refund {
@ -21,8 +21,8 @@ class WC_Gateway_Paypal_Refund {
/**
* Get refund request args.
* @param WC_Order $order
* @param float $amount
* @param string $reason
* @param float $amount
* @param string $reason
* @return array
*/
public static function get_request( $order, $amount = null, $reason = '' ) {
@ -47,9 +47,9 @@ class WC_Gateway_Paypal_Refund {
/**
* Refund an order via PayPal.
* @param WC_Order $order
* @param float $amount
* @param string $reason
* @param boolean $sandbox
* @param float $amount
* @param string $reason
* @param bool $sandbox
* @return array|wp_error The parsed response from paypal, or a WP_Error object
*/
public static function refund_order( $order, $amount = null, $reason = '', $sandbox = false ) {

View File

@ -1,7 +1,7 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
/**
@ -38,8 +38,8 @@ class WC_Gateway_Paypal_Request {
/**
* Get the PayPal request URL for an order.
* @param WC_Order $order
* @param boolean $sandbox
* @param WC_Order $order
* @param bool $sandbox
* @return string
*/
public function get_request_url( $order, $sandbox = false ) {
@ -54,8 +54,7 @@ class WC_Gateway_Paypal_Request {
/**
* Get PayPal Args for passing to PP.
*
* @param WC_Order $order
* @param WC_Order $order
* @return array
*/
protected function get_paypal_args( $order ) {
@ -236,7 +235,6 @@ class WC_Gateway_Paypal_Request {
/**
* Get line items to send to paypal.
*
* @param WC_Order $order
* @return bool
*/
@ -262,12 +260,12 @@ class WC_Gateway_Paypal_Request {
}
}
// Shipping Cost item - paypal only allows shipping per item, we want to send shipping for the order
// Shipping Cost item - paypal only allows shipping per item, we want to send shipping for the order.
if ( $order->get_total_shipping() > 0 && ! $this->add_line_item( sprintf( __( 'Shipping via %s', 'woocommerce' ), $order->get_shipping_method() ), 1, $this->round( $order->get_total_shipping(), $order ) ) ) {
return false;
}
// Check for mismatched totals
// Check for mismatched totals.
if ( $this->number_format( $calculated_total + $order->get_total_tax() + $this->round( $order->get_total_shipping(), $order ) - $this->round( $order->get_total_discount(), $order ), $order ) != $this->number_format( $order->get_total(), $order ) ) {
return false;
}
@ -277,10 +275,10 @@ class WC_Gateway_Paypal_Request {
/**
* Add PayPal Line Item.
* @param string $item_name
* @param integer $quantity
* @param integer $amount
* @param string $item_number
* @param string $item_name
* @param int $quantity
* @param int $amount
* @param string $item_number
* @return bool successfully added or not
*/
protected function add_line_item( $item_name, $quantity = 1, $amount = 0, $item_number = '' ) {
@ -320,9 +318,7 @@ class WC_Gateway_Paypal_Request {
/**
* Check if currency has decimals.
*
* @param string $currency
*
* @return bool
*/
protected function currency_has_decimals( $currency ) {
@ -335,10 +331,8 @@ class WC_Gateway_Paypal_Request {
/**
* Round prices.
*
* @param double $price
* @param WC_Order $order
*
* @return double
*/
protected function round( $price, $order ) {
@ -353,10 +347,8 @@ class WC_Gateway_Paypal_Request {
/**
* Format prices.
*
* @param float|int $price
* @param WC_Order $order
*
* @return string
*/
protected function number_format( $price, $order ) {

View File

@ -1,11 +1,11 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
/**
* Handles refunds.
* Handles Responses.
*/
abstract class WC_Gateway_Paypal_Response {
@ -14,12 +14,11 @@ abstract class WC_Gateway_Paypal_Response {
/**
* Get the order from the PayPal 'Custom' variable.
*
* @param string $raw_custom JSON Data passed back by PayPal
* @return bool|WC_Order object
*/
protected function get_paypal_order( $raw_custom ) {
// We have the data in the correct format, so get the order
// We have the data in the correct format, so get the order.
if ( ( $custom = json_decode( $raw_custom ) ) && is_object( $custom ) ) {
$order_id = $custom->order_id;
$order_key = $custom->order_key;
@ -29,14 +28,14 @@ abstract class WC_Gateway_Paypal_Response {
$order_id = $custom[0];
$order_key = $custom[1];
// Nothing was found
// Nothing was found.
} else {
WC_Gateway_Paypal::log( 'Error: Order ID and key were not found in "custom".' );
return false;
}
if ( ! $order = wc_get_order( $order_id ) ) {
// We have an invalid $order_id, probably because invoice_prefix has changed
// We have an invalid $order_id, probably because invoice_prefix has changed.
$order_id = wc_get_order_id_by_order_key( $order_key );
$order = wc_get_order( $order_id );
}
@ -52,8 +51,8 @@ abstract class WC_Gateway_Paypal_Response {
/**
* Complete order, add transaction ID and note.
* @param WC_Order $order
* @param string $txn_id
* @param string $note
* @param string $txn_id
* @param string $note
*/
protected function payment_complete( $order, $txn_id = '', $note = '' ) {
$order->add_order_note( $note );
@ -63,7 +62,7 @@ abstract class WC_Gateway_Paypal_Response {
/**
* Hold order and add note.
* @param WC_Order $order
* @param string $reason
* @param string $reason
*/
protected function payment_on_hold( $order, $reason = '' ) {
$order->update_status( 'on-hold', $reason );

View File

@ -276,7 +276,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
* process_subscription_payment function.
*
* @param WC_order $order
* @param integer $amount (default: 0)
* @param int $amount (default: 0)
* @uses Simplify_BadRequestException
* @return bool|WP_Error
*/
@ -420,7 +420,7 @@ class WC_Addons_Gateway_Simplify_Commerce extends WC_Gateway_Simplify_Commerce {
* Process a pre-order payment when the pre-order is released.
*
* @param WC_Order $order
* @return wp_error|null
* @return WP_Error|null
*/
public function process_pre_order_release_payment( $order ) {

View File

@ -158,6 +158,8 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
/**
* Check if this gateway is enabled.
*
* @return bool
*/
public function is_available() {
if ( 'yes' !== $this->enabled ) {
@ -277,8 +279,6 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
}
/**
* payment_scripts function.
*
* Outputs scripts used for simplify payment.
*/
public function payment_scripts() {
@ -377,7 +377,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
/**
* Process the payment.
*
* @param integer $order_id
* @param int $order_id
*/
public function process_payment( $order_id ) {
$cart_token = isset( $_POST['simplify_token'] ) ? wc_clean( $_POST['simplify_token'] ) : '';
@ -535,7 +535,7 @@ class WC_Gateway_Simplify_Commerce extends WC_Payment_Gateway {
}
/**
* get_icon function.
* Get gateway icon.
*
* @access public
* @return string

View File

@ -10,20 +10,41 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
* Based on EvalMath by Miles Kaufman Copyright (C) 2005 Miles Kaufmann http://www.twmagic.com/.
*/
class WC_Eval_Math {
/** @var string */
/**
* Last error.
*
* @var string
*/
public static $last_error = null;
/** @var array */
public static $v = array( 'e' => 2.71, 'pi' => 3.14 ); // variables (and constants)
/**
* Variables (and constants).
*
* @var array
*/
public static $v = array( 'e' => 2.71, 'pi' => 3.14 );
/** @var array */
public static $f = array(); // user-defined functions
/**
* User-defined functions.
*
* @var array
*/
public static $f = array();
/** @var array */
public static $vb = array( 'e', 'pi' ); // constants
/**
* Constants.
*
* @var array
*/
public static $vb = array( 'e', 'pi' );
/** @var array */
public static $fb = array(); // built-in functions
/**
* Built-in functions.
*
* @var array
*/
public static $fb = array();
/**
* Evaluate maths string.
@ -202,10 +223,16 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
return $output;
}
// evaluate postfix notation
/**
* Evaluate postfix notation.
*
* @param mixed $tokens
* @param array $vars
*
* @return mixed
*/
private static function pfx( $tokens, $vars = array() ) {
if ( $tokens == false ) return false;
$stack = new WC_Eval_Math_Stack;
foreach ( $tokens as $token ) { // nice and easy
@ -247,7 +274,13 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
return $stack->pop();
}
// trigger an error, but nicely, if need be
/**
* Trigger an error, but nicely, if need be.
*
* @param string $msg
*
* @return bool
*/
private static function trigger( $msg ) {
self::$last_error = $msg;
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
@ -258,10 +291,12 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
return false;
}
// Prints the file name, function name, and
// line number which called your function
// (not this function, then one that called
// it to begin with)
/**
* Prints the file name, function name, and
* line number which called your function
* (not this function, then one that called
* it to begin with)
*/
private static function debugPrintCallingFunction() {
$file = 'n/a';
$func = 'n/a';
@ -281,17 +316,35 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
*/
class WC_Eval_Math_Stack {
/** @var array */
/**
* Stack array.
*
* @var array
*/
public $stack = array();
/** @var integer */
/**
* Stack counter.
*
* @var integer
*/
public $count = 0;
/**
* Push value into stack.
*
* @param mixed $val
*/
public function push( $val ) {
$this->stack[ $this->count ] = $val;
$this->count++;
}
/**
* Pop value from stack.
*
* @return mixed
*/
public function pop() {
if ( $this->count > 0 ) {
$this->count--;
@ -300,6 +353,13 @@ if ( ! class_exists( 'WC_Eval_Math' ) ) {
return null;
}
/**
* Get last value from stack.
*
* @param int $n
*
* @return mixed
*/
public function last( $n=1 ) {
$key = $this->count - $n;
return array_key_exists( $key, $this->stack ) ? $this->stack[ $key ] : null;

View File

@ -31,7 +31,7 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
}
/**
* init function.
* Initialize local pickup.
*/
public function init() {
@ -52,6 +52,7 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
/**
* calculate_shipping function.
* Calculate local pickup shipping.
*/
public function calculate_shipping( $package = array() ) {
$this->add_rate( array(
@ -61,7 +62,7 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
}
/**
* init_form_fields function.
* Init form fields.
*/
public function init_form_fields() {
$this->instance_form_fields = array(
@ -162,7 +163,7 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
}
/**
* clean function.
* Clean code string.
*
* @access public
* @param mixed $code

View File

@ -17,10 +17,27 @@ if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker' ) ) :
class WC_Product_Cat_Dropdown_Walker extends Walker {
/**
* What the class handles.
*
* @var string
*/
public $tree_type = 'category';
public $db_fields = array ('parent' => 'parent', 'id' => 'term_id', 'slug' => 'slug' );
/**
* 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
*

Some files were not shown because too many files have changed in this diff Show More