' . __( 'Attribute updated successfully', 'woocommerce' ) . '
' . $product->order_item_qty . ' | +' . get_the_title( $product->product_id ) . ' | +' . $this->sales_sparkline( $product->product_id, 7, 'count' ) . ' | +
' . __( 'No products found in range', 'woocommerce' ) . ' |
' . esc_html( $page_name ) . ': | '; - echo '[?] | '; - - $error = false; + if ( $page_id ) { + $page_name = '' . esc_html( $page_name ) . ''; + } else { + $page_name = esc_html( $page_name ); + } - $page_id = get_option( $values['option'] ); + echo ' | ||||||||
' . $page_name . ': | '; + echo '[?] | ';
// Page ID check
if ( ! $page_id ) {
diff --git a/includes/api/class-wc-api-orders.php b/includes/api/class-wc-api-orders.php
index f4660eaeec318..3bf0f7bd27062 100644
--- a/includes/api/class-wc-api-orders.php
+++ b/includes/api/class-wc-api-orders.php
@@ -441,7 +441,7 @@ public function create_order( $data ) {
wc_delete_shop_order_transients( $order->id );
- do_action( 'woocommerce_api_create_order', $order->id, $this );
+ do_action( 'woocommerce_api_create_order', $order->id, $data );
return $this->get_order( $order->id );
@@ -593,7 +593,7 @@ public function edit_order( $id, $data ) {
wc_delete_shop_order_transients( $order->id );
- do_action( 'woocommerce_api_edit_order', $order->id, $this );
+ do_action( 'woocommerce_api_edit_order', $order->id, $data );
return $this->get_order( $id );
diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php
index 4a1472ab0100c..5a39d4f23270a 100644
--- a/includes/api/class-wc-api-products.php
+++ b/includes/api/class-wc-api-products.php
@@ -66,6 +66,11 @@ public function register_routes( $routes ) {
array( array( $this, 'get_product_category' ), WC_API_Server::READABLE ),
);
+ # GET /products/sku/ ' . __( 'Sorry, your session has expired.', 'woocommerce' ) . ' ' . __( 'Return to homepage', 'woocommerce' ) . ' ';
+ $data = array(
+ 'fragments' => apply_filters( 'woocommerce_update_order_review_fragments', array(
+ '.woocommerce-checkout' => '' . __( 'Sorry, your session has expired.', 'woocommerce' ) . ' ' . __( 'Return to homepage', 'woocommerce' ) . ' '
+ ) )
+ );
+
+ wp_send_json( $data );
+
die();
}
@@ -253,7 +261,22 @@ public static function update_order_review() {
WC()->cart->calculate_totals();
- do_action( 'woocommerce_checkout_order_review', true ); // Display review order table
+ ob_start();
+ woocommerce_order_review();
+ $woocommerce_order_review = ob_get_clean();
+
+ ob_start();
+ woocommerce_checkout_payment();
+ $woocommerce_checkout_payment = ob_get_clean();
+
+ $data = array(
+ 'fragments' => apply_filters( 'woocommerce_update_order_review_fragments', array(
+ '.woocommerce-checkout-review-order-table' => $woocommerce_order_review,
+ '.woocommerce-checkout-payment' => $woocommerce_checkout_payment
+ ) )
+ );
+
+ wp_send_json( $data );
die();
}
@@ -311,32 +334,17 @@ public static function checkout() {
* Feature a product from admin
*/
public static function feature_product() {
- if ( ! current_user_can( 'edit_products' ) ) {
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce' ), '', array( 'response' => 403 ) );
- }
+ if ( current_user_can( 'edit_products' ) && check_admin_referer( 'woocommerce-feature-product' ) ) {
+ $product_id = absint( $_GET['product_id'] );
- if ( ! check_admin_referer( 'woocommerce-feature-product' ) ) {
- wp_die( __( 'You have taken too long. Please go back and retry.', 'woocommerce' ), '', array( 'response' => 403 ) );
- }
-
- $post_id = ! empty( $_GET['product_id'] ) ? (int) $_GET['product_id'] : '';
+ if ( 'product' === get_post_type( $product_id ) ) {
+ update_post_meta( $product_id, '_featured', get_post_meta( $product_id, '_featured', true ) === 'yes' ? 'no' : 'yes' );
- if ( ! $post_id || get_post_type( $post_id ) !== 'product' ) {
- die;
- }
-
- $featured = get_post_meta( $post_id, '_featured', true );
-
- if ( 'yes' === $featured ) {
- update_post_meta( $post_id, '_featured', 'no' );
- } else {
- update_post_meta( $post_id, '_featured', 'yes' );
+ delete_transient( 'wc_featured_products' );
+ }
}
- delete_transient( 'wc_featured_products' );
-
wp_safe_redirect( wp_get_referer() ? remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'ids' ), wp_get_referer() ) : admin_url( 'edit.php?post_type=shop_order' ) );
-
die();
}
@@ -344,31 +352,17 @@ public static function feature_product() {
* Mark an order with a status
*/
public static function mark_order_status() {
- if ( ! current_user_can( 'edit_shop_orders' ) ) {
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce' ), '', array( 'response' => 403 ) );
- }
-
- if ( ! check_admin_referer( 'woocommerce-mark-order-status' ) ) {
- wp_die( __( 'You have taken too long. Please go back and retry.', 'woocommerce' ), '', array( 'response' => 403 ) );
- }
-
- $status = isset( $_GET['status'] ) ? esc_attr( $_GET['status'] ) : '';
- $order_statuses = wc_get_order_statuses();
-
- if ( ! $status || ! isset( $order_statuses[ 'wc-' . $status ] ) ) {
- die();
- }
+ if ( current_user_can( 'edit_shop_orders' ) && check_admin_referer( 'woocommerce-mark-order-status' ) ) {
+ $status = sanitize_text_field( $_GET['status'] );
+ $order_id = absint( $_GET['order_id'] );
- $order_id = isset( $_GET['order_id'] ) && (int) $_GET['order_id'] ? (int) $_GET['order_id'] : '';
- if ( ! $order_id ) {
- die();
+ if ( wc_is_order_status( 'wc-' . $status ) && $order_id ) {
+ $order = wc_get_order( $order_id );
+ $order->update_status( $status );
+ }
}
- $order = wc_get_order( $order_id );
- $order->update_status( $status );
-
wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'edit.php?post_type=shop_order' ) );
-
die();
}
@@ -403,28 +397,10 @@ public static function add_new_attribute() {
die();
}
- /**
- * Delete variation via ajax function
- */
- public static function remove_variation() {
-
- check_ajax_referer( 'delete-variation', 'security' );
-
- $variation_id = intval( $_POST['variation_id'] );
- $variation = get_post( $variation_id );
-
- if ( $variation && 'product_variation' == $variation->post_type ) {
- wp_delete_post( $variation_id );
- }
-
- die();
- }
-
/**
* Delete variations via ajax function
*/
public static function remove_variations() {
-
check_ajax_referer( 'delete-variations', 'security' );
$variation_ids = (array) $_POST['variation_ids'];
diff --git a/includes/class-wc-cart.php b/includes/class-wc-cart.php
index 235bfe5b7c6cf..68f57d4cdf1ff 100644
--- a/includes/class-wc-cart.php
+++ b/includes/class-wc-cart.php
@@ -709,7 +709,7 @@ private function get_cart_for_session() {
}
/**
- * Returns a specific itme in the cart
+ * Returns a specific item in the cart
*
* @return array item data
*/
diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php
index b956116fb85a6..d9ec0da005382 100644
--- a/includes/class-wc-countries.php
+++ b/includes/class-wc-countries.php
@@ -975,4 +975,4 @@ public function get_address_fields( $country = '', $type = 'billing_' ) {
// Return
return $address_fields;
}
-}
+}
\ No newline at end of file
diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php
index 10439962eca30..92074ce07c19c 100644
--- a/includes/class-wc-form-handler.php
+++ b/includes/class-wc-form-handler.php
@@ -388,7 +388,7 @@ public static function update_cart_action() {
}
wc_add_notice( sprintf( __( '%s removed. %sUndo?%s', 'woocommerce' ), $product->get_title(), '', '' ) );
- $referer = wp_get_referer() ? remove_query_arg( array( 'remove_item' ), wp_get_referer() ) : WC()->cart->get_cart_url();
+ $referer = wp_get_referer() ? remove_query_arg( array( 'remove_item', 'add-to-cart', 'added-to-cart' ), add_query_arg( 'removed_item', '1', wp_get_referer() ) ) : WC()->cart->get_cart_url();
wp_safe_redirect( $referer );
exit;
diff --git a/includes/class-wc-payment-gateways.php b/includes/class-wc-payment-gateways.php
index e3a60f70f352b..14c924f009012 100644
--- a/includes/class-wc-payment-gateways.php
+++ b/includes/class-wc-payment-gateways.php
@@ -151,6 +151,20 @@ public function get_available_payment_gateways() {
return apply_filters( 'woocommerce_available_payment_gateways', $_available_gateways );
}
+ /**
+ * Set the current, active gateway
+ */
+ public function set_current_gateway( $gateways ) {
+ $default = get_option( 'woocommerce_default_gateway', current( array_keys( $gateways ) ) );
+ $current = WC()->session->get( 'chosen_payment_method', $default );
+
+ if ( isset( $gateways[ $current ] ) ) {
+ $gateways[ $current ]->set_current();
+ } elseif ( isset( $gateways[ $default ] ) ) {
+ $gateways[ $default ]->set_current();
+ }
+ }
+
/**
* Save options in admin.
*
diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php
index 73a8c07484cde..e542923245d79 100644
--- a/includes/class-wc-product-variation.php
+++ b/includes/class-wc-product-variation.php
@@ -171,10 +171,11 @@ public function exists() {
/**
* Wrapper for get_permalink. Adds this variations attributes to the URL.
*
+ * @param $cart item array If the cart item is passed, we can get a link containing the exact attributes selected for the variation, rather than the default attributes.
* @return string
*/
- public function get_permalink() {
- return add_query_arg( array_filter( $this->variation_data ), get_permalink( $this->id ) );
+ public function get_permalink( $cart_item = null ) {
+ return add_query_arg( array_filter( isset( $cart_item['variation'] ) ? $cart_item['variation'] : $this->variation_data ), get_permalink( $this->id ) );
}
/**
diff --git a/includes/class-wc-shortcodes.php b/includes/class-wc-shortcodes.php
index e311645af22b3..8b01ea1a55ade 100644
--- a/includes/class-wc-shortcodes.php
+++ b/includes/class-wc-shortcodes.php
@@ -500,7 +500,7 @@ public static function product_add_to_cart( $atts ) {
if ( ! empty( $atts['id'] ) ) {
$product_data = get_post( $atts['id'] );
} elseif ( ! empty( $atts['sku'] ) ) {
- $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $atts['sku'] ) );
+ $product_id = wc_get_product_id_by_sku( $atts['sku'] );
$product_data = get_post( $product_id );
} else {
return '';
@@ -546,7 +546,7 @@ public static function product_add_to_cart_url( $atts ) {
if ( isset( $atts['id'] ) ) {
$product_data = get_post( $atts['id'] );
} elseif ( isset( $atts['sku'] ) ) {
- $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $atts['sku'] ) );
+ $product_id = wc_get_product_id_by_sku( $atts['sku'] );
$product_data = get_post( $product_id );
} else {
return '';
diff --git a/includes/emails/class-wc-email.php b/includes/emails/class-wc-email.php
index c1a7ee1a8af80..1fb6ea6f7d653 100644
--- a/includes/emails/class-wc-email.php
+++ b/includes/emails/class-wc-email.php
@@ -510,11 +510,20 @@ public function admin_options() {
if ( wp_mkdir_p( dirname( get_stylesheet_directory() . '/woocommerce/' . $this->$template ) ) && ! file_exists( get_stylesheet_directory() . '/woocommerce/' . $this->$template ) ) {
// Locate template file
- $core_file = $this->template_base . $this->$template;
- $template_file = apply_filters( 'woocommerce_locate_core_template', $core_file, $this->$template, $this->template_base );
+ $core_file = $this->template_base . $this->$template;
+ $template_file = apply_filters( 'woocommerce_locate_core_template', $core_file, $this->$template, $this->template_base );
// Copy template file
copy( $template_file, get_stylesheet_directory() . '/woocommerce/' . $this->$template );
+
+ /**
+ * woocommerce_copy_email_template action hook
+ *
+ * @param string $template The copied template type
+ * @param string $email The email object
+ */
+ do_action( 'woocommerce_copy_email_template', $template, $this );
+
echo '' . __( 'Template file copied to theme.', 'woocommerce' ) . ' ' . __( 'Template file deleted from theme.', 'woocommerce' ) . '
id = 'bacs';
$this->icon = apply_filters('woocommerce_bacs_icon', '');
$this->has_fields = false;
@@ -57,12 +61,14 @@ public function __construct() {
// Customer Emails
add_action( 'woocommerce_email_before_order_table', array( $this, 'email_instructions' ), 10, 3 );
+
}
/**
* Initialise Gateway Settings Form Fields
*/
public function init_form_fields() {
+
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
@@ -95,13 +101,22 @@ public function init_form_fields() {
'type' => 'account_details'
),
);
+
}
/**
* generate_account_details_html function.
*/
public function generate_account_details_html() {
+
ob_start();
+
+ $country = WC()->countries->get_base_country();
+ $locale = $this->get_country_locale();
+
+ // Get sortcode label in the $locale array and use appropriate one
+ $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort Code', 'woocommerce' );
+
?>
: |
@@ -113,7 +128,7 @@ public function generate_account_details_html() {
|
|
- |
+ |
|
|
| |
- | - |
---|---|
- get_title(), $cart_item, $cart_item_key ); ?> - ' . sprintf( '× %s', $cart_item['quantity'] ) . '', $cart_item, $cart_item_key ); ?> - cart->get_item_data( $cart_item ); ?> - | -- cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?> - | -
+ | + |
+ get_title(), $cart_item, $cart_item_key ); ?> + ' . sprintf( '× %s', $cart_item['quantity'] ) . '', $cart_item, $cart_item_key ); ?> + cart->get_item_data( $cart_item ); ?> + | ++ cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?> + | +
- | + } + + do_action( 'woocommerce_review_order_after_cart_contents' ); + ?> + + |
+ | + |
+ | |
- | - |
name ); ?> | -- |
label ); ?> | -formatted_amount ); ?> | -
countries->tax_or_vat() ); ?> | -cart->get_taxes_total() ); ?> | + cart->get_fees() as $fee ) : ?> +
name ); ?> | ++ |
label ); ?> | +formatted_amount ); ?> |
- | + + + |
countries->tax_or_vat() ); ?> | +cart->get_taxes_total() ); ?> |
- | - |
' . apply_filters( 'woocommerce_no_available_payment_methods_message', $no_gateways_message ) . '
'; - - } - ?> -- - id="terms" /> -
- - - - -