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