-
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.
Adding support for product variants (#160)
- The plugin now supports the DK variant module (I just found out that it is a thing last week) - Variations are synced between DK and WooCommerce (WooCommerce Variants are created and deleted on sync) - Variants can also be generated from products in the UI — those are not indicated as variants in DK
- Loading branch information
1 parent
af0f0fa
commit a9a29aa
Showing
13 changed files
with
1,397 additions
and
41 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
Oops, something went wrong.