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