Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion classes/frontend-scripts.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static function init() {
private static function get_scripts() {

$ppom_price_js = ppom_get_price_table_calculation();
$dependencies = ppom_get_price_table_js_dependencies();

$register_scripts = array(
'PPOM-sm-popup' => array(
Expand All @@ -71,7 +72,7 @@ private static function get_scripts() {
),
'ppom-price' => array(
'src' => self::$scripts_url . "/js/price/{$ppom_price_js}",
'deps' => array( 'jquery', 'ppom-inputs', 'accounting' ),
'deps' => $dependencies,
'version' => self::$version,
),
'ppom-inputmask' => array(
Expand Down
17 changes: 17 additions & 0 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,23 @@ function ppom_get_price_table_calculation() {
return apply_filters( 'ppom_price_table_script', $js_script );
}

/**
* Get price table JS dependencies.
*
* @return string[]
*/
function ppom_get_price_table_js_dependencies() {
$dependencies = array( 'jquery', 'ppom-inputs' );

if ( version_compare( WC_VERSION, '10.3.0', '<' ) ) {
$dependencies[] = 'accounting';
} else{
$dependencies[] = 'wc-accounting';
}

return $dependencies;
}

function ppom_get_price_table_location() {

$location = ppom_get_option( 'ppom_price_table_location', 'after' );
Expand Down
7 changes: 2 additions & 5 deletions inc/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,11 @@ function ppom_hooks_load_input_scripts( $product, $ppom_id = null ) {

// Price display controller
$ppom_price_js = ppom_get_price_table_calculation();
$dependencies = ppom_get_price_table_js_dependencies();
wp_enqueue_script(
'ppom-price',
PPOM_URL . "/js/price/{$ppom_price_js}",
array(
'jquery',
'ppom-inputs',
'accounting',
),
$dependencies,
PPOM_VERSION,
true
);
Expand Down
7 changes: 1 addition & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4110,11 +4110,6 @@ parameters:
count: 1
path: inc/functions.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: inc/functions.php

-
message: "#^Parameter \\#1 \\$text of function esc_attr expects string, int\\<0, max\\> given\\.$#"
count: 1
Expand Down Expand Up @@ -4592,7 +4587,7 @@ parameters:

-
message: "#^If condition is always true\\.$#"
count: 2
count: 1
path: inc/hooks.php

-
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
parameters:
level: 6
dynamicConstantNames:
- WC_VERSION
paths:
- %currentWorkingDirectory%/inc
- %currentWorkingDirectory%/classes
Expand Down
Loading