product details
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* Wiaas Linked Packages Editor
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="wiaas_linked_packages" class="panel woocommerce_options_panel">
|
||||
|
||||
<div class="options_group">
|
||||
<p class="form-field">
|
||||
<label style="font-weight: bold;" for="wiaas_addon_packages"><?php esc_html_e( 'Add-ons:', 'wiaas' ); ?></label>
|
||||
<select
|
||||
class="wc-product-search"
|
||||
multiple="multiple"
|
||||
style="width: 50%;"
|
||||
id="wiaas_addon_packages"
|
||||
name="wiaas_addon_packages[]"
|
||||
data-sortable="true"
|
||||
data-placeholder="<?php esc_attr_e( 'Search for addons ...', 'wiaas' ); ?>"
|
||||
data-action="wiaas_json_search_addons"
|
||||
data-exclude="<?php echo intval( $package->get_id() ); ?>">
|
||||
<?php
|
||||
foreach ( $addons as $addon ) {
|
||||
echo '<option value="' . esc_attr( $addon->get_id() ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $addon->get_formatted_name() ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php echo wc_help_tip( __( 'This lets you choose which packages will be available as addons.', 'wiaas' ) );?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="options_group">
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function ($) {
|
||||
$("#wiaas_add_option_group").click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var data = {
|
||||
post:<?php echo isset( $_GET['post'] ) ? $_GET['post'] : 0; ?>,
|
||||
action: 'wiaas_create_empty_option_group'
|
||||
};
|
||||
|
||||
$.post(ajaxurl, data, function (response) {
|
||||
$('#wiaas_package_option_groups_list').append(response);
|
||||
});
|
||||
});
|
||||
|
||||
$('#wiaas_package_option_groups').delegate('.delete_wiaas_option_group', 'click', function (event) {
|
||||
event.preventDefault();
|
||||
if (confirm("<?php _e( 'Are you sure you would like to remove this option group?', 'wiaas' ); ?>")) {
|
||||
var id = $(this).data('id');
|
||||
$('#wiaas_option_group_' + id).slideUp().remove();
|
||||
}
|
||||
});
|
||||
|
||||
$('#wiaas_package_option_groups').delegate('.wiaas_option_group_name', 'change', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var name = $(this).val();
|
||||
var id = $(this).data('id');
|
||||
|
||||
$(`#wiaas_option_group_${id}_title`).text(name);
|
||||
|
||||
});
|
||||
|
||||
$('#wiaas_package_option_groups').delegate('.wiaas_option_group_options', 'change', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var id = $(this).data('id');
|
||||
var selected_options_ids = $(this).val() ? $(this).val().toString().split(',') : [];
|
||||
var previous_options_ids = $(this).data('selected') ? $(this).data('selected').toString().split(',') : [];
|
||||
|
||||
var added_option_id = selected_options_ids.find(id => previous_options_ids.indexOf(id) === -1);
|
||||
var removed_option_id = previous_options_ids.find(id => selected_options_ids.indexOf(id) === -1);
|
||||
|
||||
if (added_option_id) {
|
||||
$(this).children().filter(function() {
|
||||
var option_id = $(this).val();
|
||||
return option_id === added_option_id;
|
||||
}).clone().appendTo(`#wiaas_option_group_${id}_default`);
|
||||
}
|
||||
|
||||
if (removed_option_id) {
|
||||
$(`#wiaas_option_group_${id}_default`).children().
|
||||
filter(function() {
|
||||
var option_id = $(this).val();
|
||||
return option_id === removed_option_id;
|
||||
}).
|
||||
remove();
|
||||
}
|
||||
|
||||
$(this).data('selected', selected_options_ids.join(','));
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="wiaas_package_option_groups" class="wc-metaboxes-wrapper">
|
||||
<div class="toolbar toolbar-top">
|
||||
<button type="button" class="button button-primary" id="wiaas_add_option_group">
|
||||
<?php esc_html_e( 'Add new option group', 'wiaas' ); ?>
|
||||
</button>
|
||||
<span class="expand-close">
|
||||
<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'wiaas' ); ?></a>
|
||||
/
|
||||
<a href="#" class="close_all"><?php esc_html_e( 'Close', 'wiaas' ); ?></a>
|
||||
</span>
|
||||
</div>
|
||||
<div id="wiaas_package_option_groups_list" class="wc-metaboxes">
|
||||
<?php
|
||||
foreach ($option_groups as $group) {
|
||||
$group_options = isset($group['options']) ? $group['options'] : array();
|
||||
$id = $group['id'];
|
||||
|
||||
include 'html-package-options-group.php';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<span class="expand-close">
|
||||
<a href="#" class="expand_all">
|
||||
<?php esc_html_e( 'Expand', 'wiaas' ); ?>
|
||||
</a>
|
||||
/
|
||||
<a href="#" class="close_all"><?php esc_html_e( 'Close', 'wiaas' ); ?></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Wiaas Package Option Group Editor
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="wiaas_option_group_<?php echo esc_attr( $id ); ?>" class="wiaas_option_group wc-metabox closed">
|
||||
<h3>
|
||||
<a
|
||||
href="#"
|
||||
data-id="<?php echo esc_attr( $id ); ?>"
|
||||
class="delete delete_wiaas_option_group">
|
||||
<?php esc_html_e( 'Remove', 'wiaas' ); ?>
|
||||
</a>
|
||||
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'wiaas' ); ?>"></div>
|
||||
<strong id="wiaas_option_group_<?php echo esc_attr( $id ); ?>_title">
|
||||
<?php echo $group['name']; ?>
|
||||
</strong>
|
||||
</h3>
|
||||
<div class="wc-metabox-content">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label><?php esc_html_e( 'Name', 'wiaas' ); ?>:</label>
|
||||
<input
|
||||
type="text"
|
||||
data-id="<?php echo esc_attr( $id ); ?>"
|
||||
class="wiaas_option_group_name"
|
||||
name="wiaas_option_groups[<?php echo esc_attr( $id ); ?>][name]"
|
||||
value="<?php echo esc_attr( $group['name'] ); ?>" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="wiaas_option_groups[<?php echo esc_attr( $id ); ?>][id]"
|
||||
value="<?php echo esc_attr( $id ); ?>" />
|
||||
</td>
|
||||
<td rowspan="3">
|
||||
<label><?php esc_html_e( 'Options:', 'wiaas' ); ?></label>
|
||||
<select
|
||||
class="wc-product-search wiaas_option_group_options"
|
||||
multiple="multiple"
|
||||
style="width: 50%;"
|
||||
name="wiaas_option_groups[<?php echo esc_attr( $id ); ?>][options][]"
|
||||
data-id="<?php echo esc_attr( $id ); ?>"
|
||||
data-sortable="true"
|
||||
data-placeholder="<?php esc_attr_e( 'Search for options ...', 'wiaas' ); ?>"
|
||||
data-action="wiaas_json_search_options"
|
||||
data-selected="<?php echo implode( ',', array_map(function($option) { return $option->get_id(); }, $group_options)) ?>"
|
||||
data-exclude="">
|
||||
<?php
|
||||
foreach ( $group_options as $option ) {
|
||||
echo '<option value="' . esc_attr( $option->get_id() ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $option->get_formatted_name() ) . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label>
|
||||
<?php esc_html_e( 'Default option:', 'wiaas' ); ?>
|
||||
</label>
|
||||
<select
|
||||
id="wiaas_option_group_<?php echo esc_attr( $id ); ?>_default"
|
||||
name="wiaas_option_groups[<?php echo esc_attr( $id ); ?>][default]"
|
||||
>
|
||||
<?php
|
||||
foreach ( $group_options as $option ) {
|
||||
echo '<option value="' . esc_attr( $option->get_id() ) . '"' .
|
||||
selected( $option->get_id(), $group['default'], false ) .
|
||||
'>' .
|
||||
wp_kses_post( $option->get_formatted_name() ) .
|
||||
'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Wiaas Package Types Editor
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="wiaas_package_type_editor" class="options_group show_if_bundle hidden">
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function ($) {
|
||||
$("#wiaas_package_type").change(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
handlePackageTypeToolsVisiblity();
|
||||
});
|
||||
|
||||
function handlePackageTypeToolsVisiblity() {
|
||||
var currentPackageType = $('#wiaas_package_type').val();
|
||||
var productType = $('#product-type').val();
|
||||
|
||||
if (currentPackageType === 'standard' && productType === 'bundle') {
|
||||
$('#woocommerce-product-data').find('.linked_product_tab').show();
|
||||
} else {
|
||||
$('#woocommerce-product-data').find('.linked_product_tab').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function showDownloadableFiles() {
|
||||
$('#general_product_data').find('.show_if_downloadable').each(function() {
|
||||
$(this).show();
|
||||
$(this).removeClass('hidden');
|
||||
$(this).removeClass('show_if_downloadable');
|
||||
|
||||
$(this).find('._download_limit_field, ._download_expiry_field').hide();
|
||||
});
|
||||
}
|
||||
|
||||
showDownloadableFiles();
|
||||
|
||||
handlePackageTypeToolsVisiblity();
|
||||
});
|
||||
</script>
|
||||
|
||||
<p class="form-field">
|
||||
<label for="wiaas_package_type"><?php esc_html_e( 'Package type:', 'wiaas' ); ?></label>
|
||||
<select id="wiaas_package_type" name="wiaas_package_type">
|
||||
<?php
|
||||
// Array of available package types
|
||||
$package_types = Wiaas_Package_Type::get_available_package_types();
|
||||
|
||||
$current_package_type = Wiaas_Package_Type::get_package_type($package->get_id());
|
||||
$current_package_type = isset($current_package_type) ? $current_package_type : 'standard';
|
||||
|
||||
if ( ! empty( $package_types ) ) {
|
||||
foreach ( $package_types as $package_type ) {
|
||||
$label = '';
|
||||
switch($package_type) {
|
||||
case 'standard':
|
||||
$label = 'Standard';
|
||||
break;
|
||||
case 'option':
|
||||
$label = 'Option';
|
||||
break;
|
||||
case 'add_on':
|
||||
$label = 'Add-on';
|
||||
break;
|
||||
}
|
||||
|
||||
echo '<option ' .
|
||||
'value="' . esc_attr( $package_type ) . '" ' .
|
||||
selected( $package_type, $current_package_type, false ) .
|
||||
' >' .
|
||||
esc_html( $label ) .
|
||||
'</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php echo wc_help_tip( __( 'Choose Wiaas package type.', 'wiaas' ) );?>
|
||||
</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user