-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Reading sync settings from variant's parents instead of the variant itself - Adding a bulk action and supporting JS that changes simple products into product variants
- Loading branch information
1 parent
03b26ce
commit a98da51
Showing
8 changed files
with
262 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
class NineteenEightyWooProducts { | ||
static actionSelect() { | ||
return document.getElementById( 'bulk-action-selector-top' ); | ||
} | ||
|
||
static addProductIdInputToActions() { | ||
let actionsContainer = document.querySelector( '#posts-filter .bulkactions' ); | ||
let actionButton = document.getElementById( 'doaction' ); | ||
let productIdInput = document.createElement( 'input' ); | ||
let spacerTextNode = document.createTextNode( ' ' ); | ||
|
||
productIdInput.setAttribute( 'type', 'text' ); | ||
productIdInput.setAttribute( 'name', 'action_post_id' ); | ||
productIdInput.setAttribute( 'id', 'action_post_id_input' ); | ||
productIdInput.setAttribute( 'placeholder', 'Parent ID' ); | ||
|
||
actionsContainer.insertBefore( productIdInput, actionButton ); | ||
actionsContainer.insertBefore( spacerTextNode, actionButton ); | ||
} | ||
|
||
static removeProductInputFromActions() { | ||
let element = document.getElementById( 'action_post_id_input' ); | ||
|
||
if ( element !== null ) { | ||
element.remove(); | ||
} | ||
} | ||
|
||
static selectMenuEvent( e ) { | ||
if ( e.target.value == 'convert_to_variant' ) { | ||
NineteenEightyWooProducts.addProductIdInputToActions(); | ||
} else { | ||
NineteenEightyWooProducts.removeProductInputFromActions(); | ||
} | ||
} | ||
} | ||
|
||
window.addEventListener( | ||
'DOMContentLoaded', | ||
() => { | ||
NineteenEightyWooProducts.actionSelect().addEventListener( | ||
'change', | ||
( e ) => { | ||
NineteenEightyWooProducts.selectMenuEvent( e ); | ||
} | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
input#action_post_id_input { | ||
width: 7em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters