Handle bundle pricing on separate page
This commit is contained in:
@@ -11,6 +11,8 @@ class Wiaas_Admin_Package_Pricing {
|
|||||||
|
|
||||||
public static function init() {
|
public static function init() {
|
||||||
|
|
||||||
|
add_action( 'admin_menu', array(__CLASS__, 'add_package_pricing_editor_page') );
|
||||||
|
|
||||||
add_action( 'woocommerce_product_data_tabs', array( __CLASS__, 'package_data_tabs' ) );
|
add_action( 'woocommerce_product_data_tabs', array( __CLASS__, 'package_data_tabs' ) );
|
||||||
add_action( 'woocommerce_product_data_panels', array( __CLASS__, 'package_data_panel' ) );
|
add_action( 'woocommerce_product_data_panels', array( __CLASS__, 'package_data_panel' ) );
|
||||||
|
|
||||||
@@ -19,6 +21,18 @@ class Wiaas_Admin_Package_Pricing {
|
|||||||
add_action( 'woocommerce_process_product_meta', array( __CLASS__, 'process_meta_box' ), 1, 2 );
|
add_action( 'woocommerce_process_product_meta', array( __CLASS__, 'process_meta_box' ), 1, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function add_package_pricing_editor_page() {
|
||||||
|
|
||||||
|
add_submenu_page(
|
||||||
|
'edit.php?post_type=product',
|
||||||
|
__( 'Products', 'wiaas' ),
|
||||||
|
null,
|
||||||
|
'create_products',
|
||||||
|
'wiaas-package_price_editor',
|
||||||
|
array(__CLASS__, 'package_data_panel')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and renders new empty package pricing rule
|
* Creates and renders new empty package pricing rule
|
||||||
*/
|
*/
|
||||||
@@ -54,8 +68,8 @@ class Wiaas_Admin_Package_Pricing {
|
|||||||
*/
|
*/
|
||||||
public static function package_data_panel() {
|
public static function package_data_panel() {
|
||||||
|
|
||||||
global $post;
|
$package_id = absint($_GET['id']);
|
||||||
$package = wc_get_product( $post->ID );
|
$package = wc_get_product( $package_id );
|
||||||
$pricing_rules = Wiaas_Package_Pricing::get_package_prices($package);
|
$pricing_rules = Wiaas_Package_Pricing::get_package_prices($package);
|
||||||
$commission = Wiaas_Package_Pricing::get_package_pricing_commission($package);
|
$commission = Wiaas_Package_Pricing::get_package_pricing_commission($package);
|
||||||
$max_cost_margin = Wiaas_Package_Pricing::get_package_max_cost_margin($package);
|
$max_cost_margin = Wiaas_Package_Pricing::get_package_max_cost_margin($package);
|
||||||
|
|||||||
@@ -143,81 +143,114 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="options_group">
|
<div class="wrap">
|
||||||
<?php
|
<div class="poststuff">
|
||||||
woocommerce_wp_text_input(
|
<div id="post-body" class="metabox-holder columns-2">
|
||||||
array(
|
|
||||||
'id' => '_wiaas_max_cost_margin',
|
|
||||||
'name' => 'wiaas_max_cost_margin',
|
|
||||||
'value' => $max_cost_margin,
|
|
||||||
'label' => __( 'Max cost margin:', 'wiaas' ),
|
|
||||||
'type' => 'number',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="options_group">
|
<div id="postbox-container-1" class="postbox-container">
|
||||||
<?php
|
|
||||||
woocommerce_wp_text_input(
|
|
||||||
array(
|
|
||||||
'id' => '_wiaas_price_commision',
|
|
||||||
'name' => 'wiaas_pricing_rules_commision',
|
|
||||||
'value' => $commission,
|
|
||||||
'label' => __( 'Commision (Percent):', 'wiaas' ),
|
|
||||||
'type' => 'number',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="options_group">
|
<div class="postbox">
|
||||||
<div class="wc-metaboxes-wrapper">
|
<div class="inside">
|
||||||
<?php
|
<div class="panel-wrap">
|
||||||
$has_available_pay_types = false;
|
|
||||||
$available_pay_types = Wiaas_Package_Pricing::get_available_pay_types();
|
|
||||||
foreach ($available_pay_types as $name => $pay_type) {
|
|
||||||
if (!isset($pricing_rule_sets[$name])) {
|
|
||||||
$has_available_pay_types = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$class = $has_available_pay_types ? '' : 'wiaas_hidden';
|
<div class="panel">
|
||||||
|
<h3>Test</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
?>
|
</div>
|
||||||
<div id="wiaas_package_price_controls" class="toolbar toolbar-top <?php echo $class ?>">
|
</div>
|
||||||
<select id="wiaas_pay_type" name="wiaas-pay-type" class="pricing_rule_mode">
|
</div>
|
||||||
<?php
|
|
||||||
foreach ($available_pay_types as $name => $pay_type) {
|
|
||||||
?>
|
|
||||||
<option
|
|
||||||
value="<?php echo $name ?>"
|
|
||||||
id="wiaas_pay_type_<?php echo $name ?>"
|
|
||||||
class="<?php echo $class ?>"
|
|
||||||
>
|
|
||||||
<?php _e( $pay_type['title'], 'wiaas' ); ?>
|
|
||||||
</option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
<button
|
|
||||||
title="<?php _e( 'Add pricing type.', 'wiaas' ); ?>"
|
|
||||||
id="wiaas-add-pricing"
|
|
||||||
type="button"
|
|
||||||
class="button button-primary">
|
|
||||||
<?php _e( 'Add Pricing Type', 'wiaas' ); ?>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wiaas_package_pricing_rules" class="wc-metaboxes">
|
<div id="postbox-container-2" class="postbox-container">
|
||||||
<?php
|
|
||||||
require 'html-package-pricing-rules-list.php';
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<div class="postbox">
|
||||||
|
<div class="inside">
|
||||||
|
<div class="panel-wrap">
|
||||||
|
<div class="wrap">
|
||||||
|
<div class="options_group">
|
||||||
|
<?php
|
||||||
|
woocommerce_wp_text_input(
|
||||||
|
array(
|
||||||
|
'id' => '_wiaas_max_cost_margin',
|
||||||
|
'name' => 'wiaas_max_cost_margin',
|
||||||
|
'value' => $max_cost_margin,
|
||||||
|
'label' => __( 'Max cost margin:', 'wiaas' ),
|
||||||
|
'type' => 'number',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="options_group">
|
||||||
|
<?php
|
||||||
|
woocommerce_wp_text_input(
|
||||||
|
array(
|
||||||
|
'id' => '_wiaas_price_commision',
|
||||||
|
'name' => 'wiaas_pricing_rules_commision',
|
||||||
|
'value' => $commission,
|
||||||
|
'label' => __( 'Commision (Percent):', 'wiaas' ),
|
||||||
|
'type' => 'number',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="options_group">
|
||||||
|
<div class="wc-metaboxes-wrapper">
|
||||||
|
<?php
|
||||||
|
$has_available_pay_types = false;
|
||||||
|
$available_pay_types = Wiaas_Package_Pricing::get_available_pay_types();
|
||||||
|
foreach ($available_pay_types as $name => $pay_type) {
|
||||||
|
if (!isset($pricing_rule_sets[$name])) {
|
||||||
|
$has_available_pay_types = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = $has_available_pay_types ? '' : 'wiaas_hidden';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div id="wiaas_package_price_controls" class="toolbar toolbar-top <?php echo $class ?>">
|
||||||
|
<select id="wiaas_pay_type" name="wiaas-pay-type" class="pricing_rule_mode">
|
||||||
|
<?php
|
||||||
|
foreach ($available_pay_types as $name => $pay_type) {
|
||||||
|
?>
|
||||||
|
<option
|
||||||
|
value="<?php echo $name ?>"
|
||||||
|
id="wiaas_pay_type_<?php echo $name ?>"
|
||||||
|
class="<?php echo $class ?>"
|
||||||
|
>
|
||||||
|
<?php _e( $pay_type['title'], 'wiaas' ); ?>
|
||||||
|
</option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<button
|
||||||
|
title="<?php _e( 'Add pricing type.', 'wiaas' ); ?>"
|
||||||
|
id="wiaas-add-pricing"
|
||||||
|
type="button"
|
||||||
|
class="button button-primary">
|
||||||
|
<?php _e( 'Add Pricing Type', 'wiaas' ); ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="wiaas_package_pricing_rules" class="wc-metaboxes">
|
||||||
|
<?php
|
||||||
|
require 'html-package-pricing-rules-list.php';
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user