Merge branch 'master' of github.com:woothemes/woocommerce

This commit is contained in:
Nicola Mustone 2015-07-31 17:15:13 +02:00
commit 4f13387881
23 changed files with 220 additions and 108 deletions

File diff suppressed because one or more lines are too long

View File

@ -2735,6 +2735,40 @@ img.help_tip {
}
}
}
.woocommerce_variation {
h3 {
.sort {
cursor: move;
text-align: center;
vertical-align: middle;
float: right;
height: 26px;
width: 17px;
display: none;
vertical-align: middle;
margin-right: .5em;
color: #a0a5aa;
&:before {
content: "\e032";
font-family: 'WooCommerce';
text-align: center;
cursor: move;
line-height: 1;
display: block;
width: 17px;
line-height: 28px;
}
&:hover {
color: #777;
}
}
}
h3:hover, &.ui-sortable-helper {
.sort {
display: block;
}
}
}
.woocommerce_options_panel {
box-sizing: border-box;
@ -3053,7 +3087,11 @@ img.help_tip {
}
}
h3:hover {
&.woocommerce_variation h3 {
cursor: pointer;
}
h3:hover, &.ui-sortable-helper {
a.delete, .handlediv {
display: block;
}

View File

@ -13,7 +13,9 @@ jQuery( function( $ ) {
$( '#variable_product_options' )
.on( 'change', 'input.variable_is_downloadable', this.variable_is_downloadable )
.on( 'change', 'input.variable_is_virtual', this.variable_is_virtual )
.on( 'change', 'input.variable_manage_stock', this.variable_manage_stock );
.on( 'change', 'input.variable_manage_stock', this.variable_manage_stock )
.on( 'click', 'button.notice-dismiss', this.notice_dismiss )
.on( 'click', 'h3 .sort', this.set_menu_order );
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock' ).change();
@ -55,6 +57,13 @@ jQuery( function( $ ) {
}
},
/**
* Notice dismiss
*/
notice_dismiss: function() {
$( this ).closest( 'div.notice' ).remove();
},
/**
* Run actions when variations is loaded
*/
@ -109,6 +118,21 @@ jQuery( function( $ ) {
});
});
// Allow sorting
jQuery( '.woocommerce_variations' ).sortable({
items : '.woocommerce_variation',
cursor : 'move',
axis : 'y',
handle : '.sort',
scrollSensitivity : 40,
forcePlaceholderSize: true,
helper : 'clone',
opacity : 0.65,
stop : function () {
wc_meta_boxes_product_variations_actions.variation_row_indexes();
}
});
$( document.body ).trigger( 'wc-enhanced-select-init' );
},
@ -122,6 +146,34 @@ jQuery( function( $ ) {
if ( 1 === qty ) {
wc_meta_boxes_product_variations_actions.variations_loaded();
}
},
/**
* Lets the user manually input menu order to move items around pages
*/
set_menu_order: function( event ) {
event.preventDefault();
var $menu_order = $( this ).closest( '.woocommerce_variation' ).find('.variation_menu_order');
var value = window.prompt( woocommerce_admin_meta_boxes_variations.i18n_enter_menu_order, $menu_order.val() );
if ( value != null ) {
// Set value, save changes and reload view
$menu_order.val( parseInt( value, 10 ) ).change();
wc_meta_boxes_product_variations_ajax.save_variations();
}
},
/**
* Set menu order
*/
variation_row_indexes: function() {
var wrapper = $( '#variable_product_options .woocommerce_variations' ),
current_page = parseInt( wrapper.attr( 'data-page' ), 10 ),
offset = parseInt( ( current_page - 1 ) * woocommerce_admin_meta_boxes_variations.variations_per_page, 10 );
$( '.woocommerce_variations .woocommerce_variation' ).each( function ( index, el ) {
$( '.variation_menu_order', el ).val( parseInt( $( el ).index( '.woocommerce_variations .woocommerce_variation' ), 10 ) + 1 + offset ).change();
});
}
};
@ -879,6 +931,8 @@ jQuery( function( $ ) {
var selected = parseInt( $( this ).val(), 10 ),
wrapper = $( '#variable_product_options .woocommerce_variations' );
$( '.variations-pagenav .page-selector' ).val( selected );
wc_meta_boxes_product_variations_ajax.check_for_changes();
wc_meta_boxes_product_variations_pagenav.change_classes( selected, parseInt( wrapper.attr( 'data-total_pages' ), 10 ) );
wc_meta_boxes_product_variations_ajax.load_variations( selected );

File diff suppressed because one or more lines are too long

View File

@ -61,7 +61,7 @@ jQuery( function ( $ ) {
// Meta-Boxes - Open/close
$( '.wc-metaboxes-wrapper' ).on( 'click', '.wc-metabox h3', function( event ) {
// If the user clicks on some form input inside the h3, like a select list (for variations), the box should not be toggled
if ( $( event.target ).filter( ':input, option' ).length ) {
if ( $( event.target ).filter( ':input, option, .sort' ).length ) {
return;
}

View File

@ -1 +1 @@
jQuery(function(a){function b(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}b(),a("#titlediv #title").keyup(function(b){var c=b.keyCode||b.which;return"9"===c&&a("#woocommerce-coupon-description").size()>0?(b.stopPropagation(),a("#woocommerce-coupon-description").focus(),!1):void 0}),a(function(){a(".wc-metabox > h3").click(function(){a(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})}),a(document.body).on("wc-init-tabbed-panels",function(){a("ul.wc-tabs").show(),a("ul.wc-tabs a").click(function(){var b=a(this).closest("div.panel-wrap");return a("ul.wc-tabs li",b).removeClass("active"),a(this).parent().addClass("active"),a("div.panel",b).hide(),a(a(this).attr("href")).show(),!1}),a("div.panel-wrap").each(function(){a(this).find("ul.wc-tabs li").eq(0).find("a").click()})}).trigger("wc-init-tabbed-panels"),a(document.body).on("wc-init-datepickers",function(){a(".date-picker-field, .date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0})}).trigger("wc-init-datepickers"),a(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(b){a(b.target).filter(":input, option").length||a(this).next(".wc-metabox-content").stop().slideToggle()}).on("click",".expand_all",function(){return a(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > .wc-metabox-content").show(),!1}).on("click",".close_all",function(){return a(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > .wc-metabox-content").hide(),!1}),a(".wc-metabox.closed").each(function(){a(this).find(".wc-metabox-content").hide()})});
jQuery(function(a){function b(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}b(),a("#titlediv #title").keyup(function(b){var c=b.keyCode||b.which;return"9"===c&&a("#woocommerce-coupon-description").size()>0?(b.stopPropagation(),a("#woocommerce-coupon-description").focus(),!1):void 0}),a(function(){a(".wc-metabox > h3").click(function(){a(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})}),a(document.body).on("wc-init-tabbed-panels",function(){a("ul.wc-tabs").show(),a("ul.wc-tabs a").click(function(){var b=a(this).closest("div.panel-wrap");return a("ul.wc-tabs li",b).removeClass("active"),a(this).parent().addClass("active"),a("div.panel",b).hide(),a(a(this).attr("href")).show(),!1}),a("div.panel-wrap").each(function(){a(this).find("ul.wc-tabs li").eq(0).find("a").click()})}).trigger("wc-init-tabbed-panels"),a(document.body).on("wc-init-datepickers",function(){a(".date-picker-field, .date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0})}).trigger("wc-init-datepickers"),a(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(b){a(b.target).filter(":input, option, .sort").length||a(this).next(".wc-metabox-content").stop().slideToggle()}).on("click",".expand_all",function(){return a(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > .wc-metabox-content").show(),!1}).on("click",".close_all",function(){return a(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > .wc-metabox-content").hide(),!1}),a(".wc-metabox.closed").each(function(){a(this).find(".wc-metabox-content").hide()})});

View File

@ -48,7 +48,7 @@
$el.text( $el.attr( 'data-' + data_attribute ) );
}
});
$form.find( '.woocommerce-variation-description' ).remove();
$form.wc_variations_description_update( '' );
$form.trigger( 'reset_image' );
$form.find( '.single_variation_wrap' ).slideUp( 200 ).trigger( 'hide_variation' );
} )
@ -165,7 +165,6 @@
variation_caption = variation.image_caption,
variation_title = variation.image_title;
$form.find( '.variations_button' ).show();
$form.find( '.single_variation' ).html( variation.price_html + variation.availability_html );
if ( o_src === undefined ) {
@ -241,10 +240,11 @@
$dimensions.text( $dimensions.attr( 'data-o_dimensions' ) );
}
$single_variation_wrap.find( '.quantity' ).show();
var hide_qty = false;
var hide_qty_button = false;
if ( ! variation.is_purchasable || ! variation.is_in_stock || ! variation.variation_is_visible ) {
$form.find( '.variations_button' ).hide();
hide_qty_button = true;
}
if ( ! variation.variation_is_visible ) {
@ -265,16 +265,37 @@
if ( variation.is_sold_individually === 'yes' ) {
$single_variation_wrap.find( '.quantity input.qty' ).val( '1' );
hide_qty = true;
}
// Show/hide qty container
if ( hide_qty ) {
$single_variation_wrap.find( '.quantity' ).hide();
} else {
// No need to hide it when hiding its container
if ( ! hide_qty_button ) {
$single_variation_wrap.find( '.quantity' ).show();
}
}
// display variation description
$form.find( '.woocommerce-variation-description' ).remove();
if ( variation.variation_description ) {
$form.find( '.single_variation_wrap' ).prepend( '<div class="woocommerce-variation-description">' + variation.variation_description + '</div>' );
// Show/hide qty & button container
if ( hide_qty_button ) {
if ( $single_variation_wrap.is( ':visible' ) ) {
$form.find( '.variations_button' ).slideUp( 200 );
} else {
$form.find( '.variations_button' ).hide();
}
} else {
if ( $single_variation_wrap.is( ':visible' ) ) {
$form.find( '.variations_button' ).slideDown( 200 );
} else {
$form.find( '.variations_button' ).show();
}
}
// Refresh variation description
$form.wc_variations_description_update( variation.variation_description );
$single_variation_wrap.slideDown( 200 ).trigger( 'show_variation', [ variation ] );
})
@ -469,6 +490,48 @@
}
};
/**
* Performs animated variation description refreshes
*/
$.fn.wc_variations_description_update = function( variation_description ) {
var $form = this;
var $variations_description = $form.find( '.woocommerce-variation-description' );
if ( $variations_description.length === 0 ) {
if ( variation_description ) {
// add transparent border to allow correct height measurement when children have top/bottom margins
$form.find( '.single_variation_wrap' ).prepend( $( '<div class="woocommerce-variation-description" style="border:1px solid transparent;">' + variation_description + '</div>' ).hide() );
$form.find( '.woocommerce-variation-description' ).slideDown( 200 );
}
} else {
var load_height = $variations_description.outerHeight( true );
var new_height = 0;
var animate_height = false;
// lock height
$variations_description.css( 'height', load_height );
// replace html
$variations_description.html( variation_description );
// measure height
$variations_description.css( 'height', 'auto' );
new_height = $variations_description.outerHeight( true );
if ( Math.abs( new_height - load_height ) > 1 ) {
animate_height = true;
// lock height
$variations_description.css( 'height', load_height );
}
// animate height
if ( animate_height ) {
$variations_description.animate( { 'height' : new_height }, { duration: 200, queue: false, always: function() {
$variations_description.css( { 'height' : 'auto' } );
} } );
}
}
};
$( function() {
if ( typeof wc_add_to_cart_variation_params !== 'undefined' ) {
$( '.variations_form' ).each( function() {

File diff suppressed because one or more lines are too long

0
assets/js/jquery-serializejson/jquery.serializejson.js Executable file → Normal file
View File

0
assets/js/jquery-serializejson/jquery.serializejson.min.js vendored Executable file → Normal file
View File

View File

@ -2067,7 +2067,7 @@ I'm ordering mine next week";s:7:"POST__n";s:10:"a80bd2f042";s:21:"POST__wp_http
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_regular_price</wp:meta_key>
<wp:meta_value><![CDATA[]]></wp:meta_value>
<wp:meta_value><![CDATA[20]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_sale_price</wp:meta_key>
@ -2865,7 +2865,7 @@ I'm ordering mine next week";s:7:"POST__n";s:10:"a80bd2f042";s:21:"POST__wp_http
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_regular_price</wp:meta_key>
<wp:meta_value><![CDATA[]]></wp:meta_value>
<wp:meta_value><![CDATA[30]]></wp:meta_value>
</wp:postmeta>
<wp:postmeta>
<wp:meta_key>_sale_price</wp:meta_key>

View File

@ -175,6 +175,7 @@ class WC_Admin_Assets {
'bulk_edit_variations_nonce' => wp_create_nonce( 'bulk-edit-variations' ),
'i18n_link_all_variations' => esc_js( __( 'Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max 50 per run).', 'woocommerce' ) ),
'i18n_enter_a_value' => esc_js( __( 'Enter a value', 'woocommerce' ) ),
'i18n_enter_menu_order' => esc_js( __( 'Set variation sort-order priority', 'woocommerce' ) ),
'i18n_enter_a_value_fixed_or_percent' => esc_js( __( 'Enter a value (fixed or %)', 'woocommerce' ) ),
'i18n_delete_all_variations' => esc_js( __( 'Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce' ) ),
'i18n_last_warning' => esc_js( __( 'Last warning, are you sure?', 'woocommerce' ) ),
@ -185,7 +186,7 @@ class WC_Admin_Assets {
'i18n_no_variations_added' => esc_js( __( "No variations added", 'woocommerce' ) ),
'i18n_remove_variation' => esc_js( __( 'Are you sure you want to remove this variation?', 'woocommerce' ) ),
'i18n_scheduled_sale_start' => esc_js( __( 'Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_scheduled_sale_end' => esc_js( __( 'Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce' ) ),
'i18n_edited_variations' => esc_js( __( 'Save changes before changing page?', 'woocommerce' ) ),
'i18n_variation_count_single' => esc_js( __( '%qty% variation', 'woocommerce' ) ),
'i18n_variation_count_plural' => esc_js( __( '%qty% variations', 'woocommerce' ) ),

View File

@ -488,12 +488,11 @@ class WC_Admin_Settings {
// Image width settings
case 'image_width' :
$image_size = str_replace( '_image_size', '', $value[ 'id' ] );
$size = wc_get_image_size( $image_size );
$width = isset( $size[ 'width' ] ) ? $size[ 'width' ] : $value[ 'default' ][ 'width' ];
$height = isset( $size[ 'height' ] ) ? $size[ 'height' ] : $value[ 'default' ][ 'height' ];
$crop = isset( $size[ 'crop' ] ) ? $size[ 'crop' ] : $value[ 'default' ][ 'crop' ];
$image_size = str_replace( '_image_size', '', $value[ 'id' ] );
$size = wc_get_image_size( $image_size );
$width = isset( $size[ 'width' ] ) ? $size[ 'width' ] : $value[ 'default' ][ 'width' ];
$height = isset( $size[ 'height' ] ) ? $size[ 'height' ] : $value[ 'default' ][ 'height' ];
$crop = isset( $size[ 'crop' ] ) ? $size[ 'crop' ] : $value[ 'default' ][ 'crop' ];
$disabled_attr = '';
$disabled_message = '';
@ -691,14 +690,14 @@ class WC_Admin_Settings {
$value = array_filter( array_map( 'wc_clean', (array) $raw_value ) );
break;
case 'image_width' :
if ( isset( $option_value['width'] ) ) {
$update_options[ $option['id'] ]['width'] = wc_clean( $value['width'] );
$update_options[ $option['id'] ]['height'] = wc_clean( $value['height'] );
$update_options[ $option['id'] ]['crop'] = isset( $value['crop'] ) ? 1 : 0;
if ( isset( $raw_value['width'] ) ) {
$value['width'] = wc_clean( $raw_value['width'] );
$value['height'] = wc_clean( $raw_value['height'] );
$value['crop'] = isset( $raw_value['crop'] ) ? 1 : 0;
} else {
$update_options[ $option['id'] ]['width'] = $option['default']['width'];
$update_options[ $option['id'] ]['height'] = $option['default']['height'];
$update_options[ $option['id'] ]['crop'] = $option['default']['crop'];
$value['width'] = $option['default']['width'];
$value['height'] = $option['default']['height'];
$value['crop'] = $option['default']['crop'];
}
break;
default :

View File

@ -16,6 +16,7 @@ extract( $variation_data );
<h3>
<a href="#" class="remove_variation delete" rel="<?php echo esc_attr( $variation_id ); ?>"><?php _e( 'Remove', 'woocommerce' ); ?></a>
<div class="handlediv" title="<?php _e( 'Click to toggle', 'woocommerce' ); ?>"></div>
<div class="sort" title="<?php _e( 'Click to set menu order, or drag and drop', 'woocommerce' ); ?>"></div>
<strong>#<?php echo esc_html( $variation_id ); ?>: </strong>
<?php
foreach ( $parent_data['attributes'] as $attribute ) {
@ -55,7 +56,7 @@ extract( $variation_data );
}
?>
<input type="hidden" name="variable_post_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $variation_id ); ?>" />
<input type="hidden" class="variation_menu_order" name="variation_menu_order[<?php echo $loop; ?>]" value="<?php echo $loop; ?>" />
<input type="hidden" class="variation_menu_order" name="variation_menu_order[<?php echo $loop; ?>]" value="<?php echo absint( $menu_order ); ?>" />
</h3>
<div class="woocommerce_variable_attributes wc-metabox-content" style="display: none;">
<div class="data">
@ -126,20 +127,21 @@ extract( $variation_data );
</select>
</p>
</div>
<div class="">
<p class="form-row form-row-full">
<label><?php _e( 'Stock status', 'woocommerce' ); ?> <a class="tips" data-tip="<?php esc_attr_e( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ); ?>" href="#">[?]</a></label>
<select name="variable_stock_status[<?php echo $loop; ?>]">
<?php
foreach ( $parent_data['stock_status_options'] as $key => $value ) {
echo '<option value="' . esc_attr( $key === $_stock_status ? '' : $key ) . '" ' . selected( $key === $_stock_status, true, false ) . '>' . esc_html( $value ) . '</option>';
}
?>
</select>
</p>
</div>
<?php endif; ?>
<div class="">
<p class="form-row form-row-full">
<label><?php _e( 'Stock status', 'woocommerce' ); ?> <a class="tips" data-tip="<?php esc_attr_e( 'Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce' ); ?>" href="#">[?]</a></label>
<select name="variable_stock_status[<?php echo $loop; ?>]">
<?php
foreach ( $parent_data['stock_status_options'] as $key => $value ) {
echo '<option value="' . esc_attr( $key === $_stock_status ? '' : $key ) . '" ' . selected( $key === $_stock_status, true, false ) . '>' . esc_html( $value ) . '</option>';
}
?>
</select>
</p>
</div>
<?php if ( wc_product_weight_enabled() || wc_product_dimensions_enabled() ) : ?>
<div>
<?php if ( wc_product_weight_enabled() ) : ?>

View File

@ -321,7 +321,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
// Total orders and discounts also includes those which have been refunded at some point
$this->report_data->total_orders = absint( array_sum( wp_list_pluck( $this->report_data->order_counts, 'count' ) ) );
$this->report_data->total_coupons = number_format( array_sum( wp_list_pluck( $this->report_data->coupons, 'discount_amount' ) ), 2 );
$this->report_data->total_coupons = number_format( array_sum( wp_list_pluck( $this->report_data->coupons, 'discount_amount' ) ), 2, '.', '' );
$this->report_data->total_refunded_orders = absint( count( $this->report_data->full_refunds ) );
// Item counts

View File

@ -84,11 +84,6 @@ class WC_API_Products extends WC_API_Resource {
array( array( $this, 'delete_product_attribute' ), WC_API_Server::DELETABLE ),
);
# GET /products/sku/<product sku>
$routes[ $this->base . '/sku/(?P<sku>\w[\w\s\-]*)' ] = array(
array( array( $this, 'get_product_by_sku' ), WC_API_Server::READABLE ),
);
# POST|PUT /products/bulk
$routes[ $this->base . '/bulk' ] = array(
array( array( $this, 'bulk' ), WC_API_Server::EDITABLE | WC_API_Server::ACCEPT_DATA ),
@ -161,7 +156,7 @@ class WC_API_Products extends WC_API_Resource {
}
// add the parent product data to an individual variation
if ( $product->is_type( 'variation' ) ) {
if ( $product->is_type( 'variation' ) && $product->parent ) {
$product_data['parent'] = $this->get_product_data( $product->parent );
}
@ -2300,30 +2295,6 @@ class WC_API_Products extends WC_API_Resource {
}
}
/**
* Get product by SKU
*
* @deprecated 2.4.0
*
* @since 2.3.0
* @param int $sku the product SKU
* @param string $fields
* @return array
*/
public function get_product_by_sku( $sku, $fields = null ) {
try {
$id = wc_get_product_id_by_sku( $sku );
if ( empty( $id ) ) {
throw new WC_API_Exception( 'woocommerce_api_invalid_product_sku', __( 'Invalid product SKU', 'woocommerce' ), 404 );
}
return $this->get_product( $id, $fields );
} catch ( WC_API_Exception $e ) {
return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
}
}
/**
* Clear product
*/

View File

@ -161,7 +161,7 @@ class WC_API_Products extends WC_API_Resource {
}
// add the parent product data to an individual variation
if ( $product->is_type( 'variation' ) ) {
if ( $product->is_type( 'variation' ) && $product->parent ) {
$product_data['parent'] = $this->get_product_data( $product->parent );
}

View File

@ -21,35 +21,17 @@ class WC_AJAX {
* Hook in ajax handlers
*/
public static function init() {
add_action( 'init', array( __CLASS__, 'add_endpoint') );
add_action( 'template_redirect', array( __CLASS__, 'do_wc_ajax'), 0 );
self::add_ajax_events();
}
/**
* Add our endpoint for frontend ajax requests
*/
public static function add_endpoint() {
add_rewrite_tag( '%wc-ajax%', '([^/]*)' );
add_rewrite_rule( 'wc-ajax/([^/]*)/?', 'index.php?wc-ajax=$matches[1]', 'top' );
add_rewrite_rule( 'index.php/wc-ajax/([^/]*)/?', 'index.php?wc-ajax=$matches[1]', 'top' );
}
/**
* Get WC Ajax Endpoint
* @param string $request Optional
* @return string
*/
public static function get_endpoint( $request = '' ) {
if ( strstr( get_option( 'permalink_structure' ), '/index.php/' ) ) {
$endpoint = trailingslashit( home_url( '/index.php/wc-ajax/' . $request, 'relative' ) );
} elseif ( get_option( 'permalink_structure' ) ) {
$endpoint = trailingslashit( home_url( '/wc-ajax/' . $request, 'relative' ) );
} else {
$endpoint = add_query_arg( $request ? 'wc-ajax' : 'wc-ajax=', $request, trailingslashit( home_url( '', 'relative' ) ) );
}
return esc_url_raw( $endpoint );
return esc_url_raw( add_query_arg( 'wc-ajax', $request ) );
}
/**
@ -749,7 +731,8 @@ class WC_AJAX {
'post_status' => 'publish',
'post_author' => get_current_user_id(),
'post_parent' => $post_id,
'post_type' => 'product_variation'
'post_type' => 'product_variation',
'menu_order' => -1
);
$variation_id = wp_insert_post( $variation );
@ -2481,15 +2464,15 @@ class WC_AJAX {
}
// Get variations
$args = array(
$args = apply_filters( 'woocommerce_ajax_admin_get_variations_args', array(
'post_type' => 'product_variation',
'post_status' => array( 'private', 'publish' ),
'posts_per_page' => $per_page,
'paged' => $page,
'orderby' => 'ID',
'order' => 'DESC',
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => $product_id
);
), $product_id );
$variations = get_posts( $args );
$loop = 0;
@ -2542,6 +2525,7 @@ class WC_AJAX {
$variation_data['_thumbnail_id'] = absint( $variation_data['_thumbnail_id'] );
$variation_data['image'] = $variation_data['_thumbnail_id'] ? wp_get_attachment_thumb_url( $variation_data['_thumbnail_id'] ) : '';
$variation_data['shipping_class'] = $shipping_classes && ! is_wp_error( $shipping_classes ) ? current( $shipping_classes )->term_id : '';
$variation_data['menu_order'] = $variation->menu_order;
// Stock BW compat
if ( '' !== $variation_data['_stock'] ) {
@ -2582,12 +2566,13 @@ class WC_AJAX {
wc_delete_product_transients( $product_id );
if ( $errors = WC_Admin_Meta_Boxes::$meta_box_errors ) {
echo '<div id="woocommerce_errors" class="error">';
echo '<div class="error notice is-dismissible">';
foreach ( $errors as $error ) {
echo '<p>' . wp_kses_post( $error ) . '</p>';
}
echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'woocommerce' ) . '</span></button>';
echo '</div>';
delete_option( 'woocommerce_meta_box_errors' );

View File

@ -92,7 +92,6 @@ class WC_Install {
WC()->query->add_endpoints();
WC_API::add_endpoint();
WC_Auth::add_endpoint();
WC_AJAX::add_endpoint();
self::create_terms();
self::create_cron_jobs();

View File

@ -116,7 +116,7 @@ function wc_create_order( $args = array() ) {
update_post_meta( $order_id, '_order_version', WC_VERSION );
return new WC_Order( $order_id );
return wc_get_order( $order_id );
}
/**

View File

@ -765,7 +765,7 @@ function wc_get_payment_gateway_by_order( $order ) {
if ( ! is_object( $order ) ) {
$order_id = absint( $order );
$order = new WC_Order( $order_id );
$order = wc_get_order( $order_id );
}
return isset( $payment_gateways[ $order->payment_method ] ) ? $payment_gateways[ $order->payment_method ] : false;

View File

@ -14,7 +14,7 @@ class WC_Helper_Order {
*/
public static function delete_order( $order_id ) {
$order = new WC_Order( $order_id );
$order = wc_get_order( $order_id );
// Delete all products in the order
foreach ( $order->get_items() as $item ) :
@ -85,6 +85,6 @@ class WC_Helper_Order {
$order->set_total( 0, 'shipping_tax' );
$order->set_total( 40, 'total' ); // 4 x $10 simple helper product
return new WC_Order( $order->id );
return wc_get_order( $order->id );
}
}

View File

@ -3,7 +3,7 @@
* Plugin Name: WooCommerce
* Plugin URI: http://www.woothemes.com/woocommerce/
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
* Version: 2.4.0-beta-4
* Version: 2.4.0-RC1
* Author: WooThemes
* Author URI: http://woothemes.com
* Requires at least: 4.1