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