PluginProbe
Tiered Pricing Table for WooCommerce / 2.2.1
Tiered Pricing Table for WooCommerce v2.2.1
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 / SimpleProductManager.php

SimpleProductManager.php in Tiered Pricing Table for WooCommerce 2.2.1, at src/Admin/ProductManagers/SimpleProductManager.php

60 lines 1.8 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 WC_Product ;
7 /**
8 * Class SimpleProductManager
9 *
10 * @package TierPricingTable\Admin\Product
11 */
12 class SimpleProductManager extends ProductManagerAbstract
13 {
14 /**
15 * Register hooks
16 */
17 protected function hooks()
18 {
19 add_action( 'woocommerce_product_options_pricing', [ $this, 'renderPriceRules' ] );
20 add_action( 'save_post_product', [ $this, 'updatePriceRules' ] );
21 }
22
23 /**
24 * Update price quantity rules for simple product
25 *
26 * @param int $product_id
27 */
28 public function updatePriceRules( $product_id )
29 {
30
31 if ( isset( $_POST['tiered_price_fixed_quantity'] ) ) {
32 $amounts = $_POST['tiered_price_fixed_quantity'];
33 $prices = ( !empty($_POST['tiered_price_fixed_price']) ? $_POST['tiered_price_fixed_price'] : [] );
34 PriceManager::updateFixedPriceRules( $amounts, $prices, $product_id );
35 }
36
37 }
38
39 /**
40 * Render inputs for price rules on simple product
41 *
42 * @global WC_Product $product_object
43 */
44 public function renderPriceRules()
45 {
46 global $product_object ;
47
48 if ( $product_object instanceof WC_Product ) {
49 $type = PriceManager::getPricingType( $product_object->get_id() );
50 $this->fileManager->includeTemplate( 'admin/add-price-rule-simple.php', [
51 'price_rules_fixed' => PriceManager::getFixedPriceRules( $product_object->get_id() ),
52 'price_rules_percentage' => PriceManager::getPercentagePriceRules( $product_object->get_id() ),
53 'type' => $type,
54 'isFree' => $this->licence->isFree(),
55 ] );
56 }
57
58 }
59
60 }