Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * WooCommerce Pre-paid Subscriptions
- *
- * Single Product Upfront content
- *
- * This template can be overridden by copying it to YOURTHEME/woocommerce-subscription-upfront-payment/content-single-product.php.
- *
- * HOWEVER, on occasion WooCommerce Subscriptions Up-Front Payment will need to update template files and you
- * (the theme developer) will need to copy the new files to your theme to
- * maintain compatibility. We try to do this as little as possible, but it does
- * happen. When this occurs the version of the template file will be bumped and
- * the readme will list any important changes.
- *
- * @author Flycart
- * @version 1.0.0
- *
- * @var array $upfront_price original and upfront (discounted)prices
- * @var string $price_string formatted price, sign-up fee with duration
- * @var string $additional_message massage entered in product page
- * @var string $id field id
- * @var string $field_name field name
- * @var string $allow_only_upfront_pay
- * @var object $product
- */
- if (!defined('ABSPATH')) exit;
- $original_price = $upfront_price['original'];
- $discounted_price = $upfront_price['upfront'];
- $price_to_display = '';
- if($discounted_price < $original_price){
- $price_to_display = '<del>'.Flycart_WCS_PayUpFrontHelper::formatted_price($original_price).'</del> ';
- }
- $price_to_display .= Flycart_WCS_PayUpFrontHelper::formatted_price($discounted_price);
- $price_to_display .= $price_string;
- ?>
- <div class="wcs_up_front_pay_option_container woocommerce-message woocommerce-message--info woocommerce-Message woocommerce-Message--info woocommerce-info">
- <?php
- if(!empty($additional_message)){
- ?>
- <div class="subscription_up_front_pay_message">
- <?php esc_html_e($additional_message, 'woocommerce-subscription-upfront-payment'); ?>
- </div>
- <?php } ?>
- <div class="subscription_up_front_price">
- <?php echo $price_to_display; ?>
- </div>
- <?php
- if(!$allow_only_upfront_pay){
- ?>
- <div class="subscription_up_front_pay_options">
- <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>
- <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"/>
- </div>
- <script type="text/javascript">
- jQuery(document).ready(function($){
- $(document).on('click', '.wcs_pay_upfront_button_override', function(){
- $button_outer_container = $(this).closest('.subscription_up_front_pay_options');
- $form = $(this).closest('form');
- $button_outer_container.find('input[name=flycart_wcs_pay_upfront]').val(1);
- $form.find('button[type=submit]').trigger('click');
- });
- });
- </script>
- <?php
- } else {
- $product_id = $product->get_parent_id();
- if(!$product_id) $product_id = $product->get_id();
- ?>
- <style type="text/css">
- #product-<?php echo $product_id; ?> .woocommerce-variation-price,
- #product-<?php echo $product_id; ?> .entry-summary .price{
- display: none;
- }
- </style>
- <?php
- }
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement