api-keys.js
5 years ago
api-keys.min.js
2 years ago
backbone-modal.js
2 years ago
backbone-modal.min.js
2 years ago
marketplace-suggestions.js
10 months ago
marketplace-suggestions.min.js
10 months ago
meta-boxes-coupon.js
1 year ago
meta-boxes-coupon.min.js
1 year ago
meta-boxes-order.js
1 month ago
meta-boxes-order.min.js
1 month ago
meta-boxes-product-variation.js
1 year ago
meta-boxes-product-variation.min.js
1 year ago
meta-boxes-product.js
1 month ago
meta-boxes-product.min.js
1 month ago
meta-boxes.js
4 months ago
meta-boxes.min.js
4 months ago
network-orders.js
8 years ago
network-orders.min.js
2 years ago
order-attribution-admin.js
2 years ago
order-attribution-admin.min.js
2 years ago
product-editor.js
11 months ago
product-editor.min.js
11 months ago
product-ordering.js
3 months ago
product-ordering.min.js
3 months ago
quick-edit.js
1 year ago
quick-edit.min.js
1 year ago
reports.js
1 year ago
reports.min.js
1 year ago
settings-views-html-settings-tax.js
1 year ago
settings-views-html-settings-tax.min.js
1 year ago
settings.js
1 year ago
settings.min.js
1 year ago
system-status.js
3 months ago
system-status.min.js
3 months ago
term-ordering.js
3 months ago
term-ordering.min.js
3 months ago
users.js
5 years ago
users.min.js
2 years ago
variation-gallery.js
1 month ago
variation-gallery.min.js
1 month ago
wc-brands-enhanced-select.js
1 year ago
wc-brands-enhanced-select.min.js
1 year ago
wc-clipboard.js
5 years ago
wc-clipboard.min.js
5 years ago
wc-customer-stock-notifications.js
10 months ago
wc-customer-stock-notifications.min.js
10 months ago
wc-enhanced-select.js
2 years ago
wc-enhanced-select.min.js
2 years ago
wc-orders.js
3 years ago
wc-orders.min.js
2 years ago
wc-product-export.js
1 year ago
wc-product-export.min.js
1 year ago
wc-product-import.js
3 years ago
wc-product-import.min.js
2 years ago
wc-recent-reviews-widget-async.js
4 months ago
wc-recent-reviews-widget-async.min.js
4 months ago
wc-setup.js
5 years ago
wc-setup.min.js
2 years ago
wc-shipping-classes.js
1 year ago
wc-shipping-classes.min.js
1 year ago
wc-shipping-providers.js
3 months ago
wc-shipping-providers.min.js
3 months ago
wc-shipping-zone-methods.js
5 months ago
wc-shipping-zone-methods.min.js
5 months ago
wc-shipping-zones.js
1 year ago
wc-shipping-zones.min.js
1 year ago
wc-status-widget-async.js
4 months ago
wc-status-widget-async.min.js
4 months ago
wc-status-widget.js
1 year ago
wc-status-widget.min.js
1 year ago
woocommerce_admin.js
1 month ago
woocommerce_admin.min.js
1 month ago
quick-edit.js
174 lines
| 1 | /*global inlineEditPost, woocommerce_admin, woocommerce_quick_edit */ |
| 2 | jQuery( |
| 3 | function( $ ) { |
| 4 | $( '#the-list' ).on( |
| 5 | 'click', |
| 6 | '.editinline', |
| 7 | function() { |
| 8 | |
| 9 | inlineEditPost.revert(); |
| 10 | |
| 11 | var post_id = $( this ).closest( 'tr' ).attr( 'id' ); |
| 12 | |
| 13 | post_id = post_id.replace( 'post-', '' ); |
| 14 | |
| 15 | var $wc_inline_data = $( '#woocommerce_inline_' + post_id ); |
| 16 | |
| 17 | var sku = $wc_inline_data.find( '.sku' ).text(), |
| 18 | regular_price = $wc_inline_data.find( '.regular_price' ).text(), |
| 19 | sale_price = $wc_inline_data.find( '.sale_price ' ).text(), |
| 20 | weight = $wc_inline_data.find( '.weight' ).text(), |
| 21 | length = $wc_inline_data.find( '.length' ).text(), |
| 22 | width = $wc_inline_data.find( '.width' ).text(), |
| 23 | height = $wc_inline_data.find( '.height' ).text(), |
| 24 | shipping_class = $wc_inline_data.find( '.shipping_class' ).text(), |
| 25 | visibility = $wc_inline_data.find( '.visibility' ).text(), |
| 26 | stock_status = $wc_inline_data.find( '.stock_status' ).text(), |
| 27 | stock = $wc_inline_data.find( '.stock' ).text(), |
| 28 | featured = $wc_inline_data.find( '.featured' ).text(), |
| 29 | manage_stock = $wc_inline_data.find( '.manage_stock' ).text(), |
| 30 | menu_order = $wc_inline_data.find( '.menu_order' ).text(), |
| 31 | tax_status = $wc_inline_data.find( '.tax_status' ).text(), |
| 32 | tax_class = $wc_inline_data.find( '.tax_class' ).text(), |
| 33 | backorders = $wc_inline_data.find( '.backorders' ).text(), |
| 34 | product_type = $wc_inline_data.find( '.product_type' ).text(); |
| 35 | |
| 36 | var formatted_regular_price = regular_price.replace( '.', woocommerce_admin.mon_decimal_point ), |
| 37 | formatted_sale_price = sale_price.replace( '.', woocommerce_admin.mon_decimal_point ); |
| 38 | |
| 39 | var cogs_data = $wc_inline_data.find( '.cogs_value ' ); |
| 40 | if( cogs_data.length > 0 ) { |
| 41 | var formatted_cogs_value = cogs_data.text().replace( '.', woocommerce_admin.mon_decimal_point ); |
| 42 | $( 'input[name="_cogs_value"]', '.inline-edit-row' ).val( formatted_cogs_value ); |
| 43 | } |
| 44 | |
| 45 | $( 'input[name="_sku"]', '.inline-edit-row' ).val( sku ); |
| 46 | $( 'input[name="_regular_price"]', '.inline-edit-row' ).val( formatted_regular_price ); |
| 47 | $( 'input[name="_sale_price"]', '.inline-edit-row' ).val( formatted_sale_price ); |
| 48 | $( 'input[name="_weight"]', '.inline-edit-row' ).val( weight ); |
| 49 | $( 'input[name="_length"]', '.inline-edit-row' ).val( length ); |
| 50 | $( 'input[name="_width"]', '.inline-edit-row' ).val( width ); |
| 51 | $( 'input[name="_height"]', '.inline-edit-row' ).val( height ); |
| 52 | |
| 53 | $( 'select[name="_shipping_class"] option:selected', '.inline-edit-row' ).attr( 'selected', false ).trigger( 'change' ); |
| 54 | $( 'select[name="_shipping_class"] option[value="' + shipping_class + '"]' ).attr( 'selected', 'selected' ) |
| 55 | .trigger( 'change' ); |
| 56 | |
| 57 | $( 'input[name="_stock"]', '.inline-edit-row' ).val( stock ); |
| 58 | $( 'input[name="menu_order"]', '.inline-edit-row' ).val( menu_order ); |
| 59 | |
| 60 | $( |
| 61 | 'select[name="_tax_status"] option, ' + |
| 62 | 'select[name="_tax_class"] option, ' + |
| 63 | 'select[name="_visibility"] option, ' + |
| 64 | 'select[name="_stock_status"] option, ' + |
| 65 | 'select[name="_backorders"] option' |
| 66 | ).prop( 'selected', false ).removeAttr( 'selected' ); |
| 67 | |
| 68 | var is_variable_product = 'variable' === product_type; |
| 69 | $( 'select[name="_stock_status"] ~ .wc-quick-edit-warning', '.inline-edit-row' ).toggle( is_variable_product ); |
| 70 | $( 'select[name="_stock_status"] option[value="' + (is_variable_product ? '' : stock_status) + '"]', '.inline-edit-row' ) |
| 71 | .attr( 'selected', 'selected' ); |
| 72 | |
| 73 | $( 'select[name="_tax_status"] option[value="' + tax_status + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); |
| 74 | $( 'select[name="_tax_class"] option[value="' + tax_class + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); |
| 75 | $( 'select[name="_visibility"] option[value="' + visibility + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); |
| 76 | $( 'select[name="_backorders"] option[value="' + backorders + '"]', '.inline-edit-row' ).attr( 'selected', 'selected' ); |
| 77 | |
| 78 | if ( 'yes' === featured ) { |
| 79 | $( 'input[name="_featured"]', '.inline-edit-row' ).prop( 'checked', true ); |
| 80 | } else { |
| 81 | $( 'input[name="_featured"]', '.inline-edit-row' ).prop( 'checked', false ); |
| 82 | } |
| 83 | |
| 84 | // Conditional display. |
| 85 | var product_is_virtual = $wc_inline_data.find( '.product_is_virtual' ).text(); |
| 86 | |
| 87 | var product_supports_stock_status = 'external' !== product_type; |
| 88 | var product_supports_stock_fields = 'external' !== product_type && 'grouped' !== product_type; |
| 89 | |
| 90 | $( '.stock_fields, .manage_stock_field, .stock_status_field, .backorder_field' ).show(); |
| 91 | |
| 92 | if ( product_supports_stock_fields ) { |
| 93 | if ( 'yes' === manage_stock ) { |
| 94 | $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).show().removeAttr( 'style' ); |
| 95 | $( '.stock_status_field' ).hide(); |
| 96 | $( '.manage_stock_field input' ).prop( 'checked', true ); |
| 97 | } else { |
| 98 | $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).hide(); |
| 99 | $( '.stock_status_field' ).show().removeAttr( 'style' ); |
| 100 | $( '.manage_stock_field input' ).prop( 'checked', false ); |
| 101 | } |
| 102 | } else if ( product_supports_stock_status ) { |
| 103 | $( '.stock_fields, .manage_stock_field, .backorder_field' ).hide(); |
| 104 | } else { |
| 105 | $( '.stock_fields, .manage_stock_field, .stock_status_field, .backorder_field' ).hide(); |
| 106 | } |
| 107 | |
| 108 | if ( 'simple' === product_type || 'external' === product_type ) { |
| 109 | $( '.price_fields', '.inline-edit-row' ).show().removeAttr( 'style' ); |
| 110 | } else { |
| 111 | $( '.price_fields', '.inline-edit-row' ).hide(); |
| 112 | } |
| 113 | |
| 114 | if ( 'yes' === product_is_virtual ) { |
| 115 | $( '.dimension_fields', '.inline-edit-row' ).hide(); |
| 116 | } else { |
| 117 | $( '.dimension_fields', '.inline-edit-row' ).show().removeAttr( 'style' ); |
| 118 | } |
| 119 | |
| 120 | // Rename core strings. |
| 121 | $( 'input[name="comment_status"]' ).parent().find( '.checkbox-title' ).text( woocommerce_quick_edit.strings.allow_reviews ); |
| 122 | } |
| 123 | ); |
| 124 | |
| 125 | $( '#the-list' ).on( |
| 126 | 'change', |
| 127 | '.inline-edit-row input[name="_manage_stock"]', |
| 128 | function() { |
| 129 | |
| 130 | if ( $( this ).is( ':checked' ) ) { |
| 131 | $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).show().removeAttr( 'style' ); |
| 132 | $( '.stock_status_field' ).hide(); |
| 133 | } else { |
| 134 | $( '.stock_qty_field, .backorder_field', '.inline-edit-row' ).hide(); |
| 135 | $( '.stock_status_field' ).show().removeAttr( 'style' ); |
| 136 | } |
| 137 | |
| 138 | } |
| 139 | ); |
| 140 | |
| 141 | $( '#wpbody' ).on( |
| 142 | 'click', |
| 143 | '#doaction, #doaction2', |
| 144 | function() { |
| 145 | $( 'input.text', '.inline-edit-row' ).val( '' ); |
| 146 | $( '#woocommerce-fields' ).find( 'select' ).prop( 'selectedIndex', 0 ); |
| 147 | $( '#woocommerce-fields-bulk' ).find( '.inline-edit-group .change-input' ).hide(); |
| 148 | } |
| 149 | ); |
| 150 | |
| 151 | $( '#wpbody' ).on( |
| 152 | 'change', |
| 153 | '#woocommerce-fields-bulk .inline-edit-group .change_to', |
| 154 | function() { |
| 155 | |
| 156 | if ( 0 < $( this ).val() ) { |
| 157 | $( this ).closest( 'div' ).find( '.change-input' ).show(); |
| 158 | } else { |
| 159 | $( this ).closest( 'div' ).find( '.change-input' ).hide(); |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | ); |
| 164 | |
| 165 | $( '#wpbody' ).on( |
| 166 | 'click', |
| 167 | '.trash-product', |
| 168 | function() { |
| 169 | return window.confirm( woocommerce_admin.i18n_delete_product_notice ); |
| 170 | } |
| 171 | ); |
| 172 | } |
| 173 | ); |
| 174 |