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
1 change: 1 addition & 0 deletions classes/inputs/input.measure.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function change_option_label( $label, $option, $meta, $product ) {
}

$price = isset( $option['price'] ) ? $option['price'] : 0;
$price = apply_filters( 'ppom_option_price', $price );
$price = wc_price( $price );
$label = $price . '/' . $option['option'];

Expand Down
38 changes: 38 additions & 0 deletions classes/plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ public function __construct() {
add_filter( 'woocommerce_order_again_cart_item_data', 'ppom_wc_order_again_compatibility', 10, 3 );
// Show description tooltip.
add_filter( 'ppom_field_description', array( $this, 'show_tooltip' ), 15, 2 );

add_filter( 'ppom_option_price', array( $this, 'ppom_convert_price' ), 99, 1 );
}

/*
Expand Down Expand Up @@ -1094,4 +1096,40 @@ public function is_license_of_type( $type ) {

return false;
}

/**
* Convert price using active multi-currency plugin's filter or function.
*
* @param float|int|string|null $price The price to convert.
* @return float|int|string|null The converted price.
*/
public function ppom_convert_price( $price ) {
if ( '' === $price || null === $price ) {
return $price;
}
if ( is_string( $price ) && false !== strpos( $price, '%' ) ) {
return $price;
}
if ( ! is_numeric( $price ) ) {
return $price;
}
$numeric_price = (float) $price;

// WCML.
if ( has_filter( 'wcml_raw_price_amount' ) ) {
return apply_filters( 'wcml_raw_price_amount', $numeric_price );
}

// FOX - Currency Switcher.
if ( has_filter( 'woocs_exchange_value' ) ) {
return apply_filters( 'woocs_exchange_value', $numeric_price );
}

// CURCY - WooCommerce Multi Currency.
if ( function_exists( 'wmc_get_price' ) ) {
return wmc_get_price( $numeric_price );
}

return $price;
}
}
18 changes: 9 additions & 9 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,36 +913,36 @@ function ppom_admin_bar_menu() {
function ppom_add_black_friday_data( $configs ) {
$config = $configs['default'];

$message = __( 'Conditional fields, file uploads, pricing formulas. Let customers configure products the way they need. Exclusively for existing PPOM users.', 'woocommerce-product-addon' );
$message = __( 'Conditional fields, file uploads, pricing formulas. Let customers configure products the way they need. Exclusively for existing PPOM users.', 'woocommerce-product-addon' );
$cta_label = __( 'Get PPOM Pro', 'woocommerce-product-addon' );

$plan = apply_filters( 'product_ppom_license_plan', 0 );
$license = apply_filters( 'product_ppom_license_key', false );
$status = apply_filters( 'product_ppom_license_status', false );
$plan = apply_filters( 'product_ppom_license_plan', 0 );
$license = apply_filters( 'product_ppom_license_key', false );
$status = apply_filters( 'product_ppom_license_status', false );
$pro_product_slug = defined( 'PPOM_PRO_BASENAME' ) ? PPOM_PRO_BASENAME : '';

$is_pro = 'valid' === $status;
$is_pro = 'valid' === $status;
$is_expired = 'expired' === $status || 'active-expired' === $status;

if ( $is_pro ) {
// translators: %s is the discount percentage.
$config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - up to %s off', 'woocommerce-product-addon' ), '30%' );
// translators: %1$s - discount, %2$s - discount.
$message = sprintf( __( 'Upgrade your PPOM Pro plan: %1$s off this week. Already on the plan you need? Renew early and save up to %2$s.', 'woocommerce-product-addon' ), '30%', '20%' );
$message = sprintf( __( 'Upgrade your PPOM Pro plan: %1$s off this week. Already on the plan you need? Renew early and save up to %2$s.', 'woocommerce-product-addon' ), '30%', '20%' );
$cta_label = __( 'See your options', 'woocommerce-product-addon' );
} elseif ( $is_expired ) {
// translators: %s is the discount percentage.
$config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'woocommerce-product-addon' ), '50%' );
$message = __( 'Your PPOM Pro features are still here, just locked. Renew at a reduced rate this week.', 'woocommerce-product-addon' );
$cta_label = __( 'Reactivate now', 'woocommerce-product-addon' );
$message = __( 'Your PPOM Pro features are still here, just locked. Renew at a reduced rate this week.', 'woocommerce-product-addon' );
$cta_label = __( 'Reactivate now', 'woocommerce-product-addon' );
} else {
// translators: %s is the discount percentage.
$config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'woocommerce-product-addon' ), '60%' );
// translators: %s - discount.
$config['title'] = sprintf( __( 'PPOM Pro: %s off this week', 'woocommerce-product-addon' ), '60%' );
}

$url_params = array(
$url_params = array(
'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
'lkey' => ! empty( $license ) ? $license : false,
'expired' => $is_expired ? '1' : false,
Expand Down
17 changes: 12 additions & 5 deletions inc/nmInput.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function Regular( $args, $default_value = '' ) {
$onetime = $this->get_attribute_value( 'onetime', $args );
$taxable = $this->get_attribute_value( 'taxable', $args );
$price = $this->get_attribute_value( 'price', $args );
$price = apply_filters( 'ppom_option_price', $price );
$price_without_tax = '';

// Only title without description for price calculation etc.
Expand Down Expand Up @@ -277,8 +278,9 @@ public function Measure( $args, $default_value = '' ) {
// $measure_label = $option['label'].'/'.$
$option_id = $option['option_id'];
$unit = $option['raw'];
$price = apply_filters( 'ppom_option_price', $option['price'] );
$html .= '<input checked name="ppom[unit][' . $id . ']" value="' . esc_attr( $unit ) . '" class="form-check-input ppom-measure-unit" type="radio" id="' . esc_attr( $option_id ) . '" data-apply="measure" ';
$html .= sprintf( 'data-use_units="' . esc_attr( $use_units ) . '" data-price="%s" data-label="%s" data-data_name="%s" data-unit="%s" data-optionid="%s">', $option['price'], esc_attr( $data_label ), $id, $unit, $option_id );
$html .= sprintf( 'data-use_units="' . esc_attr( $use_units ) . '" data-price="%s" data-label="%s" data-data_name="%s" data-unit="%s" data-optionid="%s">', $price, esc_attr( $data_label ), $id, $unit, $option_id );
$html .= '<label class="form-check-label" id="' . esc_attr( $option_id ) . '">';
$html .= $option['label'];
$html .= '</label>';
Expand Down Expand Up @@ -481,7 +483,7 @@ public function Select( $args, $selected_value = '' ) {
// ppom_pa($value);

$option_label = $value['label'];
$option_price = $value['price'];
$option_price = apply_filters( 'ppom_option_price', $value['price'] );
$option_id = isset( $value['id'] ) ? $value['id'] : '';
$raw_label = $value['raw'];
$without_tax = $value['without_tax'];
Expand Down Expand Up @@ -660,7 +662,7 @@ public function Checkbox( $args, $checked_value = array() ) {
foreach ( $options as $key => $value ) {

$option_label = $value['label'];
$option_price = $value['price'];
$option_price = apply_filters( 'ppom_option_price', $value['price'] );
$raw_label = $value['raw'];
$without_tax = $value['without_tax'];
$option_id = $value['option_id'];
Expand Down Expand Up @@ -743,7 +745,7 @@ public function Radio( $args, $checked_value = '' ) {
foreach ( $options as $key => $value ) {

$option_label = $value['label'];
$option_price = $value['price'];
$option_price = apply_filters( 'ppom_option_price', $value['price'] );
$raw_label = $value['raw'];
$without_tax = $value['without_tax'];
$option_id = $value['option_id'];
Expand Down Expand Up @@ -850,7 +852,7 @@ public function Palettes( $args, $default_value = '' ) {

$color_label = $value['label'];
$option_label = $value['label'];
$option_price = $value['price'];
$option_price = apply_filters( 'ppom_option_price', $value['price'] );
$raw_label = $value['raw'];
$without_tax = $value['without_tax'];

Expand Down Expand Up @@ -974,6 +976,7 @@ public function Image( $args, $default_value = '' ) {
$image_title = isset( $image['raw'] ) ? stripslashes( $image['raw'] ) : '';
$image_label = isset( $image['label'] ) ? stripslashes( $image['label'] ) : '';
$image_price = isset( $image['price'] ) ? $image['price'] : 0;
$image_price = apply_filters( 'ppom_option_price', $image_price );
$option_id = $id . '-' . $image_id;

// If price set in %
Expand Down Expand Up @@ -1069,6 +1072,7 @@ public function Image( $args, $default_value = '' ) {
$image_title = isset( $image['raw'] ) ? stripslashes( $image['raw'] ) : '';
$image_label = isset( $image['label'] ) ? stripslashes( $image['label'] ) : '';
$image_price = isset( $image['price'] ) ? $image['price'] : 0;
$image_price = apply_filters( 'ppom_option_price', $image_price );
$option_id = $id . '-' . $image_id;

// If price set in %
Expand Down Expand Up @@ -1183,6 +1187,7 @@ public function Pricematrix( $args, $default_value = '' ) {
if ( ! $is_hidden ) {
foreach ( $ranges as $opt ) {
$price = isset( $opt['raw_price'] ) ? trim( $opt['raw_price'] ) : 0;
$price = apply_filters( 'ppom_option_price', $price );
$label = isset( $opt['label'] ) ? $opt['label'] : $opt['raw'];

if ( ! empty( $opt['percent'] ) ) {
Expand Down Expand Up @@ -1357,6 +1362,7 @@ public function Audio_video( $args, $default_value = '' ) {
$audio_id = isset( $audio['id'] ) ? $audio['id'] : 0;
$audio_title = isset( $audio['title'] ) ? stripslashes( $audio['title'] ) : 0;
$audio_price = isset( $audio['price'] ) ? $audio['price'] : 0;
$audio_price = apply_filters( 'ppom_option_price', $audio_price );

// Actually image URL is link
$audio_url = wp_get_attachment_url( $audio_id );
Expand Down Expand Up @@ -1565,6 +1571,7 @@ public function Cropper( $args, $selected_value = '' ) {

$option_label = $size['label'];
$option_price = $size['price'];
$option_price = apply_filters( 'ppom_option_price', $option_price );
$raw_label = $size['raw'];
$without_tax = $size['without_tax'];
$option_id = $size['option_id'];
Expand Down
1 change: 1 addition & 0 deletions inc/prices.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ function ppom_generate_field_price( $field_price, $field_meta, $apply, $option =
$taxable = ( isset( $field_meta['onetime_taxable'] ) && $field_meta['onetime_taxable'] == 'on' ) ? true : false;
$option_label = isset( $option['raw'] ) ? $option['raw'] : '';
$without_tax = isset( $option['without_tax'] ) ? $option['without_tax'] : '';
$field_price = apply_filters( 'ppom_option_price', $field_price );

$label_price = "{$field_title} - " . wc_price( $field_price );
// For bulkquantity
Expand Down
12 changes: 7 additions & 5 deletions inc/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ function ppom_woocommerce_mini_cart_fixed_fee() {

$item_fee = $fee->total + $fee->tax;
}
// var_dump($fee);
$item_fee = apply_filters( 'ppom_option_price', $item_fee );
$fixed_fee_html .= '<tr>';
$fixed_fee_html .= '<td class="subtotal-text">' . esc_html( $fee->name );
'</td>';
Expand Down Expand Up @@ -736,6 +736,8 @@ function ppom_woocommerce_add_item_meta( $item_meta, $cart_item ) {
$meta_name = isset( $meta['name'] ) ? $meta['name'] : '';
$meta_value = isset( $meta['value'] ) ? $meta['value'] : '';
$display = isset( $meta['display'] ) ? $meta['display'] : $meta_value;
$meta_price = isset( $meta['price'] ) ? $meta['price'] : 0;
$meta_price = apply_filters( 'ppom_option_price', $meta_price );
if ( $key == 'ppom_has_quantities' ) {
$hidden = true;
}
Expand All @@ -757,8 +759,8 @@ function ppom_woocommerce_add_item_meta( $item_meta, $cart_item ) {
$meta_value = wp_json_encode( $meta_value );
}

if ( apply_filters( 'ppom_show_option_price_cart', false ) && isset( $meta['price'] ) ) {
$meta_value .= ' (' . wc_price( $meta['price'] ) . ')';
if ( apply_filters( 'ppom_show_option_price_cart', false ) && ! empty( $meta_price ) ) {
$meta_value .= ' (' . wc_price( $meta_price ) . ')';
}

$meta_key = stripslashes( $meta_name );
Expand Down Expand Up @@ -839,8 +841,8 @@ function ppom_woocommerce_alter_price( $price, $product ) {

$least_price = floatval( $product->get_price() ) - $least_price;
$least_price = wc_format_decimal( $least_price, wc_get_price_decimals() );
// var_dump($least_price);
$price = wc_price( $least_price ) . '-' . $price;
$least_price = apply_filters( 'ppom_option_price', $least_price );
$price = wc_price( $least_price ) . '-' . $price;
} else {

foreach ( $ranges as $range ) {
Expand Down
Loading
Loading