Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. <?php
  2. /**
  3. * WooCommerce Pre-paid Subscriptions
  4. *
  5. * Single Product Upfront content
  6. *
  7. * This template can be overridden by copying it to YOURTHEME/woocommerce-subscription-upfront-payment/content-single-product.php.
  8. *
  9. * HOWEVER, on occasion WooCommerce Subscriptions Up-Front Payment will need to update template files and you
  10. * (the theme developer) will need to copy the new files to your theme to
  11. * maintain compatibility. We try to do this as little as possible, but it does
  12. * happen. When this occurs the version of the template file will be bumped and
  13. * the readme will list any important changes.
  14. *
  15. * @author Flycart
  16. * @version 1.0.0
  17. *
  18. * @var array $upfront_price original and upfront (discounted)prices
  19. * @var string $price_string formatted price, sign-up fee with duration
  20. * @var string $additional_message massage entered in product page
  21. * @var string $id field id
  22. * @var string $field_name field name
  23. * @var string $allow_only_upfront_pay
  24. * @var object $product
  25. */
  26.  
  27. if (!defined('ABSPATH')) exit;
  28.  
  29. $original_price = $upfront_price['original'];
  30. $discounted_price = $upfront_price['upfront'];
  31. $price_to_display = '';
  32. if($discounted_price < $original_price){
  33. $price_to_display = '<del>'.Flycart_WCS_PayUpFrontHelper::formatted_price($original_price).'</del> ';
  34. }
  35. $price_to_display .= Flycart_WCS_PayUpFrontHelper::formatted_price($discounted_price);
  36. $price_to_display .= $price_string;
  37. ?>
  38.  
  39. <div class="wcs_up_front_pay_option_container woocommerce-message woocommerce-message--info woocommerce-Message woocommerce-Message--info woocommerce-info">
  40. <?php
  41. if(!empty($additional_message)){
  42. ?>
  43. <div class="subscription_up_front_pay_message">
  44. <?php esc_html_e($additional_message, 'woocommerce-subscription-upfront-payment'); ?>
  45. </div>
  46. <?php } ?>
  47. <div class="subscription_up_front_price">
  48. <?php echo $price_to_display; ?>
  49. </div>
  50. <?php
  51. if(!$allow_only_upfront_pay){
  52. ?>
  53. <div class="subscription_up_front_pay_options">
  54. <button type="button" class="single_add_to_cart_button button alt wcs_pay_upfront_button_override"><?php esc_html_e('Pay up-front', 'woocommerce-subscription-upfront-payment') ; ?></button>
  55. <input id="<?php esc_attr_e($id, 'woocommerce-subscription-upfront-payment'); ?>" name="<?php esc_attr_e($field_name, 'woocommerce-subscription-upfront-payment'); ?>" value="0" type="hidden"/>
  56. </div>
  57. <script type="text/javascript">
  58. jQuery(document).ready(function($){
  59. $(document).on('click', '.wcs_pay_upfront_button_override', function(){
  60. $button_outer_container = $(this).closest('.subscription_up_front_pay_options');
  61. $form = $(this).closest('form');
  62. $button_outer_container.find('input[name=flycart_wcs_pay_upfront]').val(1);
  63. $form.find('button[type=submit]').trigger('click');
  64. });
  65. });
  66. </script>
  67. <?php
  68. } else {
  69. $product_id = $product->get_parent_id();
  70. if(!$product_id) $product_id = $product->get_id();
  71. ?>
  72. <style type="text/css">
  73. #product-<?php echo $product_id; ?> .woocommerce-variation-price,
  74. #product-<?php echo $product_id; ?> .entry-summary .price{
  75. display: none;
  76. }
  77. </style>
  78. <?php
  79. }
  80. ?>
  81. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement