PluginProbe
Tiered Pricing Table for WooCommerce / 2.2.2
Tiered Pricing Table for WooCommerce v2.2.2
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / src / Admin / ProductManagers / VariationProductManager.php

VariationProductManager.php in Tiered Pricing Table for WooCommerce 2.2.2, at src/Admin/ProductManagers/VariationProductManager.php

70 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TierPricingTable\Admin\ProductManagers;
4
5 use TierPricingTable\PriceManager ;
6 use WP_Post ;
7 /**
8 * Class VariationProduct
9 *
10 * @package TierPricingTable\Admin\Product
11 */
12 class VariationProductManager extends ProductManagerAbstract
13 {
14 /**
15 * Register hooks
16 */
17 protected function hooks()
18 {
19 add_action(
20 'woocommerce_variation_options_pricing',
21 [ $this, 'renderPriceRules' ],
22 10,
23 3
24 );
25 add_action(
26 'woocommerce_save_product_variation',
27 [ $this, 'updatePriceRules' ],
28 10,
29 3
30 );
31 }
32
33 /**
34 * Update price quantity rules for variation product
35 *
36 * @param int $variation_id
37 * @param int $loop
38 */
39 public function updatePriceRules( $variation_id, $loop )
40 {
41
42 if ( isset( $_POST['tiered_price_fixed_quantity'][$loop] ) ) {
43 $amounts = $_POST['tiered_price_fixed_quantity'][$loop];
44 $prices = ( !empty($_POST['tiered_price_fixed_price'][$loop]) ? $_POST['tiered_price_fixed_price'][$loop] : [] );
45 PriceManager::updateFixedPriceRules( $amounts, $prices, $variation_id );
46 }
47
48 }
49
50 /**
51 * Render inputs for price rules on variation
52 *
53 * @param int $loop
54 * @param array $variation_data
55 * @param WP_Post $variation
56 */
57 public function renderPriceRules( $loop, $variation_data, $variation )
58 {
59 $type = PriceManager::getPricingType( $variation->ID );
60 $this->fileManager->includeTemplate( 'admin/add-price-rule-variation.php', [
61 'price_rules_fixed' => PriceManager::getFixedPriceRules( $variation->ID ),
62 'price_rules_percentage' => PriceManager::getPercentagePriceRules( $variation->ID ),
63 'i' => $loop,
64 'variation_data' => $variation_data,
65 'type' => $type,
66 'isFree' => $this->licence->isFree(),
67 ] );
68 }
69
70 }