PluginProbe
Tiered Pricing Table for WooCommerce / 6.1.0
Tiered Pricing Table for WooCommerce v6.1.0
8.0.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 All 91 releases
tier-pricing-table / src / Admin / ProductManagers / VariationProductManager.php

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

72 lines 2.2 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 TierPricingTable\TierPricingTablePlugin ;
7 use WP_Post ;
8 /**
9 * Class VariationProduct
10 *
11 * @package TierPricingTable\Admin\Product
12 */
13 class VariationProductManager extends ProductManagerAbstract
14 {
15 /**
16 * Register hooks
17 */
18 protected function hooks()
19 {
20 new AdvanceOptionsForVariableProduct();
21 add_action(
22 'woocommerce_variation_options_pricing',
23 [ $this, 'renderPriceRules' ],
24 10,
25 3
26 );
27 add_action(
28 'woocommerce_save_product_variation',
29 [ $this, 'updatePriceRules' ],
30 10,
31 3
32 );
33 }
34
35 /**
36 * Update price quantity rules for variation product
37 *
38 * @param int $variation_id
39 * @param int $loop
40 */
41 public function updatePriceRules( $variation_id, $loop )
42 {
43
44 if ( isset( $_POST['tiered_price_fixed_quantity'][$loop] ) ) {
45 $amounts = $_POST['tiered_price_fixed_quantity'][$loop];
46 $prices = ( !empty($_POST['tiered_price_fixed_price'][$loop]) ? $_POST['tiered_price_fixed_price'][$loop] : [] );
47 PriceManager::updateFixedPriceRules( $amounts, $prices, $variation_id );
48 }
49
50 }
51
52 /**
53 * Render inputs for price rules on variation
54 *
55 * @param int $loop
56 * @param array $variation_data
57 * @param WP_Post $variation
58 */
59 public function renderPriceRules( $loop, $variation_data, $variation )
60 {
61 $this->getContainer()->getFileManager()->includeTemplate( 'admin/add-price-rules-variation.php', [
62 'price_rules_fixed' => PriceManager::getFixedPriceRules( $variation->ID, 'edit' ),
63 'price_rules_percentage' => PriceManager::getPercentagePriceRules( $variation->ID, 'edit' ),
64 'i' => $loop,
65 'minimum' => PriceManager::getProductQtyMin( $variation->ID, 'edit' ),
66 'variation_data' => $variation_data,
67 'type' => PriceManager::getPricingType( $variation->ID ),
68 'isFree' => !tpt_fs()->is_premium(),
69 ] );
70 }
71
72 }