diff --git a/admin/css/wc-cdp-admin.css b/admin/css/wc-cdp-admin.css index 00c8c7f..3b7aa08 100755 --- a/admin/css/wc-cdp-admin.css +++ b/admin/css/wc-cdp-admin.css @@ -1,4 +1,11 @@ /** * All of the CSS for your admin-specific functionality should be * included in this file. - */ \ No newline at end of file + */ +._wc_cdp_bundle_product ._wc_cdp_bundle_product_remove { + margin-left: 0.5rem; +} + +._wc_cdp_bundle_product:last-child ._wc_cdp_bundle_product_remove { + display: none; +} \ No newline at end of file diff --git a/admin/js/wc-cdp-admin.js b/admin/js/wc-cdp-admin.js index b04717f..75d1224 100755 --- a/admin/js/wc-cdp-admin.js +++ b/admin/js/wc-cdp-admin.js @@ -1,32 +1,27 @@ (function( $ ) { 'use strict'; - /** - * All of the code for your admin-facing JavaScript source - * should reside in this file. - * - * Note: It has been assumed you will write jQuery code here, so the - * $ function reference has been prepared for usage within the scope - * of this function. - * - * This enables you to define handlers, for when the DOM is ready: - * - * $(function() { - * - * }); - * - * When the window is loaded: - * - * $( window ).load(function() { - * - * }); - * - * ...and/or other possibilities. - * - * Ideally, it is not considered best practise to attach more than a - * single DOM-ready or window-load handler for a particular page. - * Although scripts in the WordPress core, Plugins and Themes may be - * practising this, we should strive to set a better example in our own work. - */ + $(function() { + + $(document.body).on('change', '._wc_cdp_bundle_product_select', function() { + console.debug('select triggered'); + if ( ! $( this ).closest( '._wc_cdp_bundle_product' ).is( ':last-child' ) ) { + return; + } + console.debug('after return check'); + var container = $( this ).closest( '._wc_cdp_products_container' ), + index = container.find( '._wc_cdp_bundle_product' ).length, + row = container.data( 'row' ).replace( /\[99999\]/g, '[' + index + ']' ); + + container.append(row); + $( document.body ).trigger( 'wc-enhanced-select-init' ); + }); + + $('._wc_cdp_bundle_product_remove').click(function(event) { + event.preventDefault(); + $(this).closest('._wc_cdp_bundle_product').remove(); + }); + }); + })( jQuery ); diff --git a/admin/partials/product-fields-search.php b/admin/partials/product-fields-search.php new file mode 100644 index 0000000..68ad408 --- /dev/null +++ b/admin/partials/product-fields-search.php @@ -0,0 +1,26 @@ +
diff --git a/admin/partials/product-fields.php b/admin/partials/product-fields.php index a39fcae..fdbb89f 100755 --- a/admin/partials/product-fields.php +++ b/admin/partials/product-fields.php @@ -11,33 +11,26 @@ * @package Wc_Cdp * @subpackage Wc_Cdp/admin/partials */ -?> -