| 1 |
<?php namespace TierPricingTable\Frontend; |
| 2 |
|
| 3 |
use TierPricingTable\Core\ServiceContainerTrait; |
| 4 |
use TierPricingTable\TierPricingTablePlugin; |
| 5 |
use WP_Post; |
| 6 |
|
| 7 |
/** |
| 8 |
* Class Frontend |
| 9 |
* |
| 10 |
* @package TierPricingTable\Frontend |
| 11 |
*/ |
| 12 |
class Frontend { |
| 13 |
|
| 14 |
use ServiceContainerTrait; |
| 15 |
|
| 16 |
public function __construct() { |
| 17 |
|
| 18 |
new PricingTableShortcode(); |
| 19 |
|
| 20 |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueueAssets' ), 10, 1 ); |
| 21 |
} |
| 22 |
|
| 23 |
public function enqueueAssets() { |
| 24 |
wp_enqueue_script( 'tiered-pricing-table-front-js', |
| 25 |
$this->getContainer()->getFileManager()->locateJSAsset( 'frontend/product-tiered-pricing-table' ), |
| 26 |
array( 'jquery' ), TierPricingTablePlugin::VERSION ); |
| 27 |
|
| 28 |
wp_enqueue_style( 'tiered-pricing-table-front-css', |
| 29 |
$this->getContainer()->getFileManager()->locateCSSAsset( 'frontend/main.css' ), null, |
| 30 |
TierPricingTablePlugin::VERSION ); |
| 31 |
|
| 32 |
wp_localize_script( 'tiered-pricing-table-front-js', 'tieredPricingGlobalData', [ |
| 33 |
'version' => TierPricingTablePlugin::VERSION, |
| 34 |
'loadVariationTieredPricingNonce' => wp_create_nonce( 'get_pricing_table' ), |
| 35 |
'isPremium' => ! tpt_fs()->can_use_premium_code() ? 'no' : 'yes', |
| 36 |
'currencyOptions' => [ |
| 37 |
'currency_symbol' => get_woocommerce_currency_symbol(), |
| 38 |
'decimal_separator' => wc_get_price_decimal_separator(), |
| 39 |
'thousand_separator' => wc_get_price_thousand_separator(), |
| 40 |
'decimals' => wc_get_price_decimals(), |
| 41 |
'price_format' => get_woocommerce_price_format(), |
| 42 |
'trim_zeros' => apply_filters( 'woocommerce_price_trim_zeros', false ), |
| 43 |
], |
| 44 |
'supportedVariableProductTypes' => TierPricingTablePlugin::getSupportedVariableProductTypes(), |
| 45 |
'supportedSimpleProductTypes' => TierPricingTablePlugin::getSupportedSimpleProductTypes(), |
| 46 |
] ); |
| 47 |
} |
| 48 |
} |
| 49 |
|