Added pricing to quickedit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/*global inlineEditPost, woocommerce_admin, woocommerce_quick_edit */
|
||||
jQuery(function( $ ) {
|
||||
$('#the-list').on('click', '.editinline', function(){
|
||||
|
||||
/**
|
||||
* Extract metadata and put it as the value for the custom field form
|
||||
*/
|
||||
inlineEditPost.revert();
|
||||
|
||||
var post_id = jQuery(this).closest('tr').attr('id');
|
||||
|
||||
post_id = post_id.replace("post-", "");
|
||||
|
||||
var $cfd_inline_data = jQuery('#package_additional_fields_inline_' + post_id),
|
||||
$wc_inline_data = jQuery('#woocommerce_inline_' + post_id );
|
||||
|
||||
jQuery('textarea[name="_package_pricing"]', '.inline-edit-row').val($cfd_inline_data.find("#_package_prices").text());
|
||||
|
||||
|
||||
/**
|
||||
* Only show custom field for appropriate types of products (simple)
|
||||
*/
|
||||
var product_type = $wc_inline_data.find('.product_type').text();
|
||||
|
||||
if (product_type==='bundle') {
|
||||
jQuery('.custom_field_demo', '.inline-edit-row').show();
|
||||
} else {
|
||||
jQuery('.custom_field_demo', '.inline-edit-row').hide();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,8 @@ class Wiaas_Product {
|
||||
public static function init() {
|
||||
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-category.php';
|
||||
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-supplier.php';
|
||||
require_once dirname( __FILE__ ) . '/product/class-wiaas-product-quick-edit.php';
|
||||
|
||||
|
||||
add_filter('woocommerce_register_post_type_product', array(__CLASS__, 'manage_product_settings'));
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Wiaas_Product_Quick_Edit {
|
||||
|
||||
public static function init() {
|
||||
|
||||
add_action('init', array(__CLASS__, 'enqueue_scripts'));
|
||||
add_action('woocommerce_product_quick_edit_end', array(__CLASS__, 'add_additional_fields_to_edit'));
|
||||
add_action('manage_product_posts_custom_column', array(__CLASS__, 'add_additional_hidden_values_to_edit'), 99, 2);
|
||||
}
|
||||
|
||||
public static function enqueue_scripts() {
|
||||
|
||||
$plugin_url = untrailingslashit(plugins_url('/', WIAAS_FILE));
|
||||
wp_enqueue_script('wiaas_quick-edit', $plugin_url . '/assets/js/wiaas-admin-product-quick-edit.js', array('jquery', 'woocommerce_admin'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function add_additional_fields_to_edit() {
|
||||
|
||||
?>
|
||||
<h4><?php esc_html_e('Pricing', 'woocommerce'); ?></h4>
|
||||
<div class="inline-edit-group">
|
||||
<h4><?php esc_html_e('Pricing', 'woocommerce'); ?></h4>
|
||||
<label class="alignleft">
|
||||
<textarea style="height: 200px;width: 300px" type="text" name="_package_pricing" class="text"
|
||||
placeholder="<?php _e('Pricing', 'woocommerce'); ?>" value=""> </textarea>
|
||||
</label>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static function add_additional_hidden_values_to_edit($column, $post_id) {
|
||||
|
||||
switch ($column) {
|
||||
case 'name' :
|
||||
$pricing = Wiaas_Package_Pricing::get_package_prices(wc_get_product($post_id));
|
||||
?>
|
||||
<div class="hidden"
|
||||
id="package_additional_fields_inline_<?php echo $post_id; ?>">
|
||||
<?php foreach ($pricing as $key => $price) {
|
||||
?>
|
||||
<div id="_package_prices"><?php echo $price['payment_type'] . ' ' ?></div>
|
||||
<div id="_package_prices"><?php echo 'Minimal fixed price: ' . $price['minimal_fixed_price'] . ' ' ?></div>
|
||||
<div id="_package_prices"><?php echo 'Minimal recurrent price: ' . $price['minimal_recurrent_price'] . ' ' ?></div>
|
||||
<div id="_package_prices"><?php echo 'Minimal services and support price: ' . $price['minimal_services_price'] . ' ' ?></div>
|
||||
<div id="_package_prices"><?php echo 'Max contract period: ' . $price['max_contract_period'] . ' ' ?></div>
|
||||
<?php if ($key === 'managed_36') {
|
||||
?>
|
||||
<div id="_package_prices"><?php echo 'Principal amount: ' . $price['principal_amount'] . ' ' ?></div><?php
|
||||
}
|
||||
?>
|
||||
<div id="_package_prices"><?php echo ' ' ?></div> <?php
|
||||
} ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Wiaas_Product_Quick_Edit::init();
|
||||
Reference in New Issue
Block a user