Merge branch 'master' into paypal-auto-capture-10563
This commit is contained in:
commit
163da08a47
File diff suppressed because one or more lines are too long
|
@ -1140,6 +1140,10 @@ p.demo_store {
|
|||
|
||||
.buttons {
|
||||
@include clearfix();
|
||||
a {
|
||||
margin-right: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2741,11 +2741,14 @@ abstract class WC_Abstract_Order {
|
|||
return false;
|
||||
}
|
||||
|
||||
$hide = apply_filters( 'woocommerce_order_hide_shipping_address', array( 'local_pickup' ), $this );
|
||||
$hide = apply_filters( 'woocommerce_order_hide_shipping_address', array( 'local_pickup' ), $this );
|
||||
$needs_address = false;
|
||||
|
||||
foreach ( $this->get_shipping_methods() as $shipping_method ) {
|
||||
if ( ! in_array( $shipping_method['method_id'], $hide ) ) {
|
||||
// Remove any instance IDs after :
|
||||
$shipping_method_id = current( explode( ':', $shipping_method['method_id'] ) );
|
||||
|
||||
if ( ! in_array( $shipping_method_id, $hide ) ) {
|
||||
$needs_address = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -271,6 +271,7 @@ class WC_Admin_Attributes {
|
|||
<form action="edit.php?post_type=product&page=product_attributes&edit=<?php echo absint( $edit ); ?>" method="post">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php do_action( 'woocommerce_before_edit_attribute_fields' ); ?>
|
||||
<tr class="form-field form-required">
|
||||
<th scope="row" valign="top">
|
||||
<label for="attribute_label"><?php _e( 'Name', 'woocommerce' ); ?></label>
|
||||
|
@ -309,7 +310,6 @@ class WC_Admin_Attributes {
|
|||
<?php endforeach; ?>
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Deprecated action in favor of product_attributes_type_selector filter.
|
||||
*
|
||||
|
@ -335,6 +335,7 @@ class WC_Admin_Attributes {
|
|||
<p class="description"><?php _e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php do_action( 'woocommerce_after_edit_attribute_fields' ) ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="submit"><input type="submit" name="save_attribute" id="submit" class="button-primary" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"></p>
|
||||
|
@ -374,7 +375,6 @@ class WC_Admin_Attributes {
|
|||
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) :
|
||||
foreach ( $attribute_taxonomies as $tax ) :
|
||||
?><tr>
|
||||
|
||||
<td>
|
||||
<strong><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product"><?php echo esc_html( $tax->attribute_label ); ?></a></strong>
|
||||
|
||||
|
@ -440,6 +440,8 @@ class WC_Admin_Attributes {
|
|||
<h2><?php _e( 'Add New Attribute', 'woocommerce' ); ?></h2>
|
||||
<p><?php _e( 'Attributes let you define extra product data, such as size or colour. You can use these attributes in the shop sidebar using the "layered nav" widgets. Please note: you cannot rename an attribute later on.', 'woocommerce' ); ?></p>
|
||||
<form action="edit.php?post_type=product&page=product_attributes" method="post">
|
||||
<?php do_action( 'woocommerce_before_add_attribute_fields' ) ?>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="attribute_label"><?php _e( 'Name', 'woocommerce' ); ?></label>
|
||||
<input name="attribute_label" id="attribute_label" type="text" value="" />
|
||||
|
@ -489,6 +491,8 @@ class WC_Admin_Attributes {
|
|||
<p class="description"><?php _e( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.', 'woocommerce' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php do_action( 'woocommerce_after_add_attribute_fields' ) ?>
|
||||
|
||||
<p class="submit"><input type="submit" name="add_new_attribute" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Add Attribute', 'woocommerce' ); ?>"></p>
|
||||
<?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?>
|
||||
</form>
|
||||
|
|
|
@ -697,7 +697,7 @@ class WC_Admin_Settings {
|
|||
// Format the value based on option type.
|
||||
switch ( $option['type'] ) {
|
||||
case 'checkbox' :
|
||||
$value = in_array( $raw_value, array( 'yes', 'no' ) ) ? $raw_value : 'no';
|
||||
$value = '1' === $raw_value || 'yes' === $raw_value ? 'yes' : 'no';
|
||||
break;
|
||||
case 'textarea' :
|
||||
$value = wp_kses_post( trim( $raw_value ) );
|
||||
|
|
|
@ -12,7 +12,11 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<div id="poststuff" class="woocommerce-reports-wide">
|
||||
<div class="postbox">
|
||||
|
||||
<h3 class="screen-reader-text"><?php echo esc_html( $ranges[ $current_range ] ); ?></h3>
|
||||
<?php if ( 'custom' === $current_range && isset( $_GET['start_date'], $_GET['end_date'] ) ) : ?>
|
||||
<h3 class="screen-reader-text"><?php echo esc_html( sprintf( _x( 'From %s to %s', 'start date and end date', 'woocommerce' ), wc_clean( $_GET['start_date'] ), wc_clean( $_GET['end_date'] ) ) ); ?></h3>
|
||||
<?php else : ?>
|
||||
<h3 class="screen-reader-text"><?php echo esc_html( $ranges[ $current_range ] ); ?></h3>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="stats_range">
|
||||
<?php $this->get_export_button(); ?>
|
||||
|
|
|
@ -1019,7 +1019,7 @@ class WC_REST_Orders_Controller extends WC_REST_Posts_Controller {
|
|||
// Create item.
|
||||
if ( is_null( $item['id'] ) ) {
|
||||
$this->set_item( $order, $line_type, $item, 'create' );
|
||||
} elseif ( $this->item_is_null( $item ) ) {
|
||||
} elseif ( $this->item_is_null( $item ) || 0 === $item['quantity'] ) {
|
||||
// Delete item.
|
||||
wc_delete_order_item( $item['id'] );
|
||||
} else {
|
||||
|
|
|
@ -3243,7 +3243,10 @@ class WC_AJAX {
|
|||
$method_id = $wpdb->get_var( $wpdb->prepare( "SELECT method_id FROM {$wpdb->prefix}woocommerce_shipping_zone_methods WHERE instance_id = %d", $instance_id ) );
|
||||
|
||||
if ( isset( $data['deleted'] ) ) {
|
||||
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
|
||||
$option_key = $shipping_method->get_instance_option_key();
|
||||
if ( $wpdb->delete( "{$wpdb->prefix}woocommerce_shipping_zone_methods", array( 'instance_id' => $instance_id ) ) ) {
|
||||
delete_option( $option_key );
|
||||
do_action( 'woocommerce_shipping_zone_method_deleted', $instance_id, $method_id, $zone_id );
|
||||
}
|
||||
continue;
|
||||
|
|
|
@ -110,10 +110,8 @@ class WC_API extends WC_Legacy_API {
|
|||
* @since 2.6.0
|
||||
*/
|
||||
private function rest_api_init() {
|
||||
global $wp_version;
|
||||
|
||||
// REST API was included starting WordPress 4.4.
|
||||
if ( version_compare( $wp_version, 4.4, '<' ) ) {
|
||||
if ( ! class_exists( 'WP_REST_Server' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ class WC_Query {
|
|||
}
|
||||
|
||||
// Special check for shops with the product archive on front
|
||||
if ( $this->is_showing_page_on_front( $q ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) {
|
||||
if ( $q->is_page() && 'page' === get_option( 'show_on_front' ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) {
|
||||
// This is a front-page shop
|
||||
$q->set( 'post_type', 'product' );
|
||||
$q->set( 'page_id', '' );
|
||||
|
|
|
@ -44,7 +44,7 @@ if ( ! empty( $shipping_classes ) ) {
|
|||
'title' => __( 'Shipping Class Costs', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'default' => '',
|
||||
'description' => sprintf( __( 'These costs can optionally be added based on the %sproduct shipping class%s.', 'woocommerce' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=product_shipping_class&post_type=product' ) . '">', '</a>' )
|
||||
'description' => sprintf( __( 'These costs can optionally be added based on the %sproduct shipping class%s.', 'woocommerce' ), '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=classes' ) . '">', '</a>' )
|
||||
);
|
||||
foreach ( $shipping_classes as $shipping_class ) {
|
||||
if ( ! isset( $shipping_class->term_id ) ) {
|
||||
|
|
|
@ -71,7 +71,7 @@ if ( ! empty( $shipping_classes ) ) {
|
|||
'title' => __( 'Shipping Class Costs', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'default' => '',
|
||||
'description' => sprintf( __( 'These costs can optionally be added based on the %sproduct shipping class%s.', 'woocommerce' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=product_shipping_class&post_type=product' ) . '">', '</a>' )
|
||||
'description' => sprintf( __( 'These costs can optionally be added based on the %sproduct shipping class%s.', 'woocommerce' ), '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping§ion=classes' ) . '">', '</a>' )
|
||||
);
|
||||
foreach ( $shipping_classes as $shipping_class ) {
|
||||
if ( ! isset( $shipping_class->term_id ) ) {
|
||||
|
|
|
@ -47,26 +47,26 @@ class WC_Product_Cat_Dropdown_Walker extends Walker {
|
|||
*/
|
||||
public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) {
|
||||
|
||||
if ( ! empty( $args['hierarchical'] ) )
|
||||
if ( ! empty( $args['hierarchical'] ) ) {
|
||||
$pad = str_repeat(' ', $depth * 3);
|
||||
else
|
||||
} else {
|
||||
$pad = '';
|
||||
}
|
||||
|
||||
$cat_name = apply_filters( 'list_product_cats', $cat->name, $cat );
|
||||
$value = isset( $args['value'] ) && $args['value'] == 'id' ? $cat->term_id : $cat->slug;
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"" . esc_attr( $value ) . "\"";
|
||||
|
||||
$value = isset( $args['value'] ) && $args['value'] == 'id' ? $cat->term_id : $cat->slug;
|
||||
|
||||
$output .= "\t<option class=\"level-$depth\" value=\"" . $value . "\"";
|
||||
|
||||
if ( $value == $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) )
|
||||
if ( $value === $args['selected'] || ( is_array( $args['selected'] ) && in_array( $value, $args['selected'] ) ) ) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
|
||||
$output .= '>';
|
||||
$output .= esc_html( $pad . _x( $cat_name, 'product category name', 'woocommerce' ) );
|
||||
|
||||
$output .= $pad . _x( $cat_name, 'product category name', 'woocommerce' );
|
||||
|
||||
if ( ! empty( $args['show_count'] ) )
|
||||
$output .= ' (' . $cat->count . ')';
|
||||
if ( ! empty( $args['show_count'] ) ) {
|
||||
$output .= ' (' . absint( $cat->count ) . ')';
|
||||
}
|
||||
|
||||
$output .= "</option>\n";
|
||||
}
|
||||
|
|
|
@ -85,13 +85,14 @@ function wc_get_raw_referer() {
|
|||
* @access public
|
||||
* @param int|array $products
|
||||
* @param bool $show_qty Should qty's be shown? Added in 2.6.0
|
||||
* @param bool $return Return message rather than add it.
|
||||
*/
|
||||
function wc_add_to_cart_message( $products, $show_qty = false ) {
|
||||
function wc_add_to_cart_message( $products, $show_qty = false, $return = false ) {
|
||||
$titles = array();
|
||||
$count = 0;
|
||||
|
||||
if ( ! is_array( $products ) ) {
|
||||
$products = array( $products );
|
||||
$products = array( $products => 1 );
|
||||
$show_qty = false;
|
||||
}
|
||||
|
||||
|
@ -115,7 +116,13 @@ function wc_add_to_cart_message( $products, $show_qty = false ) {
|
|||
$message = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( wc_get_page_permalink( 'cart' ) ), esc_html__( 'View Cart', 'woocommerce' ), esc_html( $added_text ) );
|
||||
}
|
||||
|
||||
wc_add_notice( apply_filters( 'wc_add_to_cart_message', $message, $product_id ) );
|
||||
$message = apply_filters( 'wc_add_to_cart_message', $message, $product_id );
|
||||
|
||||
if ( $return ) {
|
||||
return $message;
|
||||
} else {
|
||||
wc_add_notice( $message );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -606,7 +606,7 @@ if ( ! function_exists( 'woocommerce_product_archive_description' ) ) {
|
|||
if ( is_search() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( is_post_type_archive( 'product' ) && 0 === absint( get_query_var( 'paged' ) ) ) {
|
||||
$shop_page = get_post( wc_get_page_id( 'shop' ) );
|
||||
if ( $shop_page ) {
|
||||
|
@ -1364,7 +1364,29 @@ if ( ! function_exists( 'woocommerce_button_proceed_to_checkout' ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_widget_shopping_cart_button_view_cart' ) ) {
|
||||
|
||||
/**
|
||||
* Output the proceed to checkout button.
|
||||
*
|
||||
* @subpackage Cart
|
||||
*/
|
||||
function woocommerce_widget_shopping_cart_button_view_cart() {
|
||||
echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button wc-forward">' . __( 'View Cart', 'woocommerce' ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'woocommerce_widget_shopping_cart_proceed_to_checkout' ) ) {
|
||||
|
||||
/**
|
||||
* Output the proceed to checkout button.
|
||||
*
|
||||
* @subpackage Cart
|
||||
*/
|
||||
function woocommerce_widget_shopping_cart_proceed_to_checkout() {
|
||||
echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="button checkout wc-forward">' . __( 'Checkout', 'woocommerce' ) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
/** Mini-Cart *************************************************************/
|
||||
|
||||
|
|
|
@ -204,6 +204,11 @@ add_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_for
|
|||
add_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
|
||||
add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_payment', 20 );
|
||||
|
||||
/**
|
||||
* Cart widget
|
||||
*/
|
||||
add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 );
|
||||
add_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
|
||||
|
||||
/**
|
||||
* Cart.
|
||||
|
|
|
@ -75,14 +75,14 @@ class WC_Widget_Recently_Viewed extends WC_Widget {
|
|||
|
||||
$this->widget_start( $args, $instance );
|
||||
|
||||
echo '<ul class="product_list_widget">';
|
||||
echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
|
||||
|
||||
while ( $r->have_posts() ) {
|
||||
$r->the_post();
|
||||
wc_get_template( 'content-widget-product.php' );
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
|
||||
|
||||
$this->widget_end( $args );
|
||||
}
|
||||
|
|
|
@ -74,14 +74,14 @@ class WC_Widget_Top_Rated_Products extends WC_Widget {
|
|||
|
||||
$this->widget_start( $args, $instance );
|
||||
|
||||
echo '<ul class="product_list_widget">';
|
||||
echo apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' );
|
||||
|
||||
while ( $r->have_posts() ) {
|
||||
$r->the_post();
|
||||
wc_get_template( 'content-widget-product.php', array( 'show_rating' => true ) );
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo apply_filters( 'woocommerce_after_widget_product_list', '</ul>' );
|
||||
|
||||
$this->widget_end( $args );
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<?php if ( ! WC()->cart->is_empty() ) : ?>
|
||||
|
||||
<?php do_action( 'woocommerce_before_mini_cart_contents' ); ?>
|
||||
|
||||
|
||||
<?php
|
||||
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
|
||||
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
|
||||
|
@ -70,7 +70,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
?>
|
||||
|
||||
<?php do_action( 'woocommerce_mini_cart_contents' ); ?>
|
||||
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<li class="empty"><?php _e( 'No products in the cart.', 'woocommerce' ); ?></li>
|
||||
|
@ -86,8 +86,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<?php do_action( 'woocommerce_widget_shopping_cart_before_buttons' ); ?>
|
||||
|
||||
<p class="buttons">
|
||||
<a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="button wc-forward"><?php _e( 'View Cart', 'woocommerce' ); ?></a>
|
||||
<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="button checkout wc-forward"><?php _e( 'Checkout', 'woocommerce' ); ?></a>
|
||||
<?php do_action( 'woocommerce_widget_shopping_cart_buttons' ); ?>
|
||||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -46,7 +46,7 @@ class WC_Tests_Cart_Functions extends WC_Unit_Test_Case {
|
|||
public function test_get_checkout_url_regular() {
|
||||
// Make sure pages exist
|
||||
WC_Install::create_pages();
|
||||
|
||||
|
||||
// Get the original setting
|
||||
$o_setting = get_option( 'woocommerce_force_ssl_checkout' );
|
||||
|
||||
|
@ -154,4 +154,29 @@ class WC_Tests_Cart_Functions extends WC_Unit_Test_Case {
|
|||
|
||||
$this->assertEquals( apply_filters( 'woocommerce_get_cart_url', $cart_page_url ? $cart_page_url : '' ), wc_get_cart_url() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test wc_add_to_cart_message
|
||||
*/
|
||||
public function test_wc_add_to_cart_message() {
|
||||
$product = WC_Helper_Product::create_simple_product();
|
||||
|
||||
$message = wc_add_to_cart_message( array( $product->id => 1 ), false, true );
|
||||
$this->assertEquals( '<a href="http://example.org" class="button wc-forward">View Cart</a> “Dummy Product” has been added to your cart.', $message );
|
||||
|
||||
$message = wc_add_to_cart_message( array( $product->id => 3 ), false, true );
|
||||
$this->assertEquals( '<a href="http://example.org" class="button wc-forward">View Cart</a> “Dummy Product” has been added to your cart.', $message );
|
||||
|
||||
$message = wc_add_to_cart_message( array( $product->id => 1 ), true, true );
|
||||
$this->assertEquals( '<a href="http://example.org" class="button wc-forward">View Cart</a> “Dummy Product” has been added to your cart.', $message );
|
||||
|
||||
$message = wc_add_to_cart_message( array( $product->id => 3 ), true, true );
|
||||
$this->assertEquals( '<a href="http://example.org" class="button wc-forward">View Cart</a> 3 × “Dummy Product” have been added to your cart.', $message );
|
||||
|
||||
$message = wc_add_to_cart_message( $product->id, false, true );
|
||||
$this->assertEquals( '<a href="http://example.org" class="button wc-forward">View Cart</a> “Dummy Product” has been added to your cart.', $message );
|
||||
|
||||
$message = wc_add_to_cart_message( $product->id, true, true );
|
||||
$this->assertEquals( '<a href="http://example.org" class="button wc-forward">View Cart</a> “Dummy Product” has been added to your cart.', $message );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue