| 1 |
<div <?php echo $this->get_render_attribute_string('wrapper'); ?> > |
| 2 |
<div class="wpfnl-offerbtn-wrapper" id="wpfnl-offerbtn-wrapper" > |
| 3 |
<?php |
| 4 |
if( ('variable' === $get_product_type || 'variable-subscription' === $get_product_type) && isset($settings['offer_type']) && 'accept' === $settings['offer_type'] ) { |
| 5 |
if( isset( $settings['variation_tbl_title'] ) && !empty( $settings['variation_tbl_title'] ) ){ |
| 6 |
echo '<h5 class="wpfnl-product-variation-title">'.$settings['variation_tbl_title'].'</h5>'; |
| 7 |
} |
| 8 |
|
| 9 |
echo '<div class="has-variation-product">'; |
| 10 |
echo '<div class="wpfnl-product-variation">'; |
| 11 |
if( isset( $settings['show_product_price'] ) && 'yes' === $settings['show_product_price'] ){ |
| 12 |
echo '<span class="offer-btn-loader"></span>'; |
| 13 |
} |
| 14 |
|
| 15 |
$post_id = get_the_ID(); |
| 16 |
echo do_shortcode( '[wpf_variable_offer post_id="'.$post_id.'"]' ); |
| 17 |
echo '</div>'; |
| 18 |
} |
| 19 |
?> |
| 20 |
|
| 21 |
<div class="wpfnl-offerbtn-and-price-wrapper <?php echo 'yes' === $settings['show_product_price'] ? $settings['product_price_alignment'] : '' ?>"> |
| 22 |
<?php if( isset( $settings['show_product_price'] ) && 'yes' === $settings['show_product_price'] ){ ?> |
| 23 |
<span class="wpfnl-offer-product-price" id="wpfnl-offer-product-price"> |
| 24 |
<?php |
| 25 |
if( ( 'variable' !== $get_product_type && 'variable-subscription' !== $get_product_type ) && isset($settings['offer_type']) && 'accept' === $settings['offer_type'] ){ |
| 26 |
|
| 27 |
if( $offer_product ){ |
| 28 |
$step_type = get_post_meta( get_the_ID(), '_step_type', true ); |
| 29 |
$discount = get_post_meta( get_the_ID(), '_wpfnl_'.$step_type.'_discount', true ); |
| 30 |
$total_price = isset($response['quantity']) ? $offer_product->get_regular_price() * $response['quantity'] : $offer_product->get_regular_price(); |
| 31 |
if( isset($discount['discountApplyTo'], $discount['discountType']) && 'original' !== $discount['discountType'] ){ |
| 32 |
if( 'sale' === $discount['discountApplyTo'] ){ |
| 33 |
$sale_price = $offer_product->get_sale_price() ? $offer_product->get_sale_price() : $offer_product->get_regular_price(); |
| 34 |
}elseif( 'regular' === $discount['discountApplyTo'] ){ |
| 35 |
$sale_price = $offer_product->get_regular_price() ? $offer_product->get_regular_price() : $offer_product->get_price(); |
| 36 |
}else{ |
| 37 |
$sale_price = $offer_product->get_price(); |
| 38 |
} |
| 39 |
$product_price = \WPFunnelsPro\Wpfnl_Pro_functions::calculate_discount_price_for_widget( $discount['discountType'] , $discount['discountValue'], $sale_price ); |
| 40 |
if( $product_price != $total_price ){ |
| 41 |
echo wc_price(number_format( (float) $product_price, 2, '.', '' )).'<del>'.wc_price(number_format( (float) $total_price, 2, '.', '' )).'</del>'; |
| 42 |
}else{ |
| 43 |
echo wc_price(number_format( (float) $product_price, 2, '.', '' )); |
| 44 |
} |
| 45 |
}else{ |
| 46 |
if( $offer_product->get_sale_price() ){ |
| 47 |
$sale_price = $offer_product->get_sale_price(); |
| 48 |
$sale_price = isset($response['quantity']) ? $sale_price * $response['quantity'] : $sale_price; |
| 49 |
echo wc_price(number_format( (float) $sale_price, 2, '.', '' )).'<del>'.wc_price(number_format( (float) $total_price, 2, '.', '' )).'</del>'; |
| 50 |
}else{ |
| 51 |
echo wc_price(number_format( (float) $total_price, 2, '.', '' )); |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
?> |
| 58 |
</span> |
| 59 |
<?php } |
| 60 |
?> |
| 61 |
|
| 62 |
<a href="#" |
| 63 |
<?php echo $this->get_render_attribute_string('button'); ?> |
| 64 |
id="wpfunnels_<?php echo isset($settings['offer_button_type']) ? $settings['offer_button_type'] : ''; ?>_<?php echo isset($settings['offer_type']) ? $settings['offer_type'] : ''; ?>" |
| 65 |
data-offertype="<?php echo isset($settings['offer_button_type']) ? $settings['offer_button_type'] : ''; ?>" > |
| 66 |
<?php |
| 67 |
$enable_subtitle = isset( $settings['enable_subtitle'] ) ? $settings['enable_subtitle'] : 'no'; |
| 68 |
$subtitle_text = isset( $settings['subtitle_text'] ) ? $settings['subtitle_text'] : ''; |
| 69 |
|
| 70 |
if ( 'yes' === $enable_subtitle && ! empty( $subtitle_text ) ) { |
| 71 |
echo '<span class="text-inner-wrapper" style="display:flex;align-items:center;gap:3px;">'; |
| 72 |
$this->render_text(); |
| 73 |
echo '</span>'; |
| 74 |
echo '<small class="wpfnl-button-subtitle">' . esc_html( $subtitle_text ) . '</small>'; |
| 75 |
} else { |
| 76 |
$this->render_text(); |
| 77 |
} |
| 78 |
?> |
| 79 |
</a> |
| 80 |
|
| 81 |
</div> |
| 82 |
|
| 83 |
<?php |
| 84 |
if( ( 'variable' === $get_product_type || 'variable-subscription' === $get_product_type ) && isset($settings['offer_type']) && 'accept' === $settings['offer_type'] ) { |
| 85 |
echo '</div>'; |
| 86 |
//end ".has-variation-product" |
| 87 |
} |
| 88 |
?> |
| 89 |
|
| 90 |
</div> |
| 91 |
|
| 92 |
</div> |
| 93 |
|
| 94 |
<?php |
| 95 |
if ( did_action( 'wpfunnels/after_offer_button' ) ) { |
| 96 |
return; |
| 97 |
} |
| 98 |
if( 'accept' === $settings['offer_type'] && \WPFunnels\Wpfnl_functions::maybe_unsupported_payment_gateway() ){ |
| 99 |
/** |
| 100 |
* Fires after the offer button is displayed. |
| 101 |
* |
| 102 |
* This action hook allows developers to add custom functionality after the offer button is rendered on the page. |
| 103 |
* |
| 104 |
* @since 2.0.5 |
| 105 |
* |
| 106 |
* @param void |
| 107 |
*/ |
| 108 |
do_action( 'wpfunnels/after_offer_button' ); |
| 109 |
} |