Task 6809 | вывод цены подписочного товара как One-time Purschare

pull/36/head
Your Name 2 months ago
parent 38f9f05bf8
commit 2f70bc5a50
  1. 9
      wp-content/themes/cosmopet/modules/shop/components/single-product/component-controller.php
  2. 3
      wp-content/themes/cosmopet/templates/_pages/shop/product-single.twig
  3. 55
      wp-content/themes/cosmopet/woocommerce/single-product/product-subscription-options-prompt-radio.php

@ -147,4 +147,13 @@ add_filter('timber/context', function ($context) use ($context_for_twig) {
} }
} }
if (class_exists('WCS_ATT_Product_Schemes')) {
$schemes = WCS_ATT_Product_Schemes::get_subscription_schemes($product);
$context['has_subscription_options'] = !empty($schemes);
} else {
$context['has_subscription_options'] = false;
}
Timber::render('_pages/shop/product-single.twig', $context); Timber::render('_pages/shop/product-single.twig', $context);

@ -84,7 +84,8 @@
</div> </div>
{# Start | Цена для неподписочного товара #} {# Start | Цена для неподписочного товара #}
{% if product.get_price %}
{% if not has_subscription_options and product.get_price %}
<div class="detail__block-price"> <div class="detail__block-price">
{% if is_subscription %} {% if is_subscription %}
{% if product.get_regular_price %} {% if product.get_regular_price %}

@ -0,0 +1,55 @@
<?php
/**
* Product Subscription Options Radio Prompt Template.
*
* Override this template by copying it to 'yourtheme/woocommerce/single-product/product-subscription-options-prompt-radio.php'.
*
* On occasion, this template file may need to be updated 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.
*
* @version 4.1.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $product;
?>
<style>
.amount {
color: #1A1A1A;
font-weight: 600;
}
</style>
<ul class="wcsatt-options-prompt-radios">
<li class="wcsatt-options-prompt-radio">
<label class="wcsatt-options-prompt-label wcsatt-options-prompt-label-one-time">
<input class="wcsatt-options-prompt-action-input" type="radio" name="subscribe-to-action-input" value="no" />
<div class="wcsatt-options-prompt-action">
One-time purchase for
<b class="woocommerce-Price-amount">
<?php
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
if ( $sale_price && $regular_price > $sale_price ) {
echo '<del>' . wc_price( $regular_price ) . '</del> <ins>' . wc_price( $sale_price ) . '</ins>';
} else {
echo wc_price( $regular_price );
}
?>
</b>
</div>
</label>
</li>
<li class="wcsatt-options-prompt-radio">
<label class="wcsatt-options-prompt-label wcsatt-options-prompt-label-subscription">
<input class="wcsatt-options-prompt-action-input" type="radio" name="subscribe-to-action-input" value="yes" />
<span class="wcsatt-options-prompt-action"><?php echo wp_kses_post( $subscription_cta ); ?></span>
</label>
</li>
</ul>
Loading…
Cancel
Save