如何在woocommerce商店中的分期付款计算插件中显示产品的动态总价?

问题描述

我有woocommerce商店,也有产品选项插件和分期付款计算插件。产品选项插件会根据您的选择更改总价,但分期付款计算插件不会获取更改后的总价以进行动态重新计算。

第一部分代码属于产品选项插件,第二部分代码属于分期付款计算插件。现在如何显示由产品选项插件计算出的分期付款计算插件计算出的动态总价?

首先对行68回显总价金额进行编码。我的商店中的示例是:

example store

您可以在TaksitSeçenekleri选项卡下查看分期付款计算插件的结果。

<?php
/**
 * The javascript-based template for displayed javascript generated html code
 *
 * This template can be overridden by copying it to yourtheme/tm-extra-product-options/tc-js-templates.php
 *
 * NOTE that we may need to update template files and you
 * (the plugin or theme developer) will need to copy the new files
 * to your theme or plugin to maintain compatibility.
 *
 * @see     https://codex.wordpress.org/Javascript_Reference/wp.template
 * @author  themeComplete
 * @package WooCommerce Extra Product Options/Templates
 * @version 5.0
 */

defined( 'ABSPATH' ) || exit;
?>
<script class="tm-hidden" type="text/template" id="tmpl-tc-cart-options-popup">
    <div class='header'>
        <h3>{{{ data.title }}}</h3>
    </div>
    <div id='{{{ data.id }}}' class='float_editbox'>{{{ data.html }}}</div>
    <div class='footer'>
        <div class='inner'>
            <span class='tm-button button button-secondary button-large floatbox-cancel'>{{{ data.close }}}</span>
        </div>
    </div>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-lightbox">
    <div class="tc-lightbox-wrap">
        <span class="tc-lightbox-button tcfa tcfa-search tc-transition tcinit"></span>
    </div>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-lightbox-zoom">
    <span class="tc-lightbox-button-close tcfa tcfa-times"></span>
    {{{ data.img }}}
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-final-totals">
    <dl class="tm-extra-product-options-totals tm-custom-price-totals">
        <# if (data.show_unit_price==true){ #><?php do_action( 'wc_epo_template_before_unit_price' ); ?>
        <dt class="tm-unit-price">{{{ data.unit_price }}}</dt>
        <dd class="tm-unit-price">
            <span class="price amount options">{{{ data.formatted_unit_price }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_unit_price' ); ?>
        <# } #>
        <# if (data.show_options_total==true){ #><?php do_action( 'wc_epo_template_before_option_total' ); ?>
        <dt class="tm-options-totals">{{{ data.options_total }}}</dt>
        <dd class="tm-options-totals">
            <span class="price amount options">{{{ data.formatted_options_total }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_option_total' ); ?>
        <# } #>
        <# if (data.show_fees_total==true){ #><?php do_action( 'wc_epo_template_before_fee_total' ); ?>
        <dt class="tm-fee-totals">{{{ data.fees_total }}}</dt>
        <dd class="tm-fee-totals">
            <span class="price amount fees">{{{ data.formatted_fees_total }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_fee_total' ); ?>
        <# } #>
        <# if (data.show_extra_fee==true){ #><?php do_action( 'wc_epo_template_before_extra_fee' ); ?>
        <dt class="tm-extra-fee">{{{ data.extra_fee }}}</dt>
        <dd class="tm-extra-fee">
            <span class="price amount options extra-fee">{{{ data.formatted_extra_fee }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_extra_fee' ); ?>
        <# } #>
        <# if (data.show_final_total==true){ #><?php do_action( 'wc_epo_template_before_final_total' ); ?>
        <dt class="tm-final-totals">{{{ data.final_total }}}</dt>
        <dd class="tm-final-totals">
 line 68            <span class="price amount final">{{{ data.formatted_final_total }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_final_total' ); ?>
        <# } #>
        <?php do_action('wc_epo_after_js_final_totals'); ?>
    </dl>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-price">
    <span class="amount">{{{ data.price.price }}}</span>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-sale-price">
    <del>
        <span class="tc-original-price amount">{{{ data.price.original_price }}}</span>
    </del>
    <ins>
        <span class="amount">{{{ data.price.price }}}</span>
    </ins>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-section-pop-link">
    <div id="tm-section-pop-up" class="tm-extra-product-options flasho tm_wrapper tm-section-pop-up single tm-animated appear">
        <div class='header'><h3>{{{ data.title }}}</h3></div>
        <div class="float_editbox" id="temp_for_floatbox_insert"></div>
        <div class='footer'>
            <div class='inner'>
                <span class='tm-button button button-secondary button-large floatbox-cancel'>{{{ data.close }}}</span>
            </div>
        </div>
    </div>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-floating-box-nks">
    <# if (data.values.length) {#>
    {{{ data.html_before }}}
    <div class="tc-row tm-fb-labels">
        <span class="tc-cell tc-col-3 tm-fb-title">{{{ data.option_label }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-value">{{{ data.option_value }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-quantity">{{{ data.option__qty }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-price">{{{ data.option_lpric }}}</span>
    </div>
    <# for (var i = 0; i < data.values.length; i++) { #>
        <# if (data.values[i].label_show=='' || data.values[i].value_show=='') {#>
    <div class="tc-row">
            <# if (data.values[i].label_show=='') {#>
        <span class="tc-cell tc-col-3 tm-fb-title">{{{ data.values[i].title }}}</span>
            <# } #>
            <# if (data.values[i].value_show=='') {#>
        <span class="tc-cell tc-col-3 tm-fb-value">{{{ data.values[i].value }}}</span>
            <# } #>
        <span class="tc-cell tc-col-3 tm-fb-quantity">{{{ data.values[i].quantity }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-price">{{{ data.values[i].price }}}</span>
    </div>
        <# } #>
    <# } #>
    {{{ data.html_after }}}
    {{{ data.totals }}}
    <# }#>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-floating-box">
    <# if (data.values.length) {#>
    {{{ data.html_before }}}
    <dl class="tm-fb">
        <# for (var i = 0; i < data.values.length; i++) { #>
            <# if (data.values[i].label_show=='') {#>
        <dt class="tm-fb-title">{{{ data.values[i].title }}}</dt>
            <# } #>
            <# if (data.values[i].value_show=='') {#>
        <dd class="tm-fb-value">{{{ data.values[i].value }}}</dd>
            <# } #>
        <# } #>
    </dl>
    {{{ data.html_after }}}
    {{{ data.totals }}}
    <# }#>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-chars-remanining">
    <span class="tc-chars">
        <span class="tc-chars-remanining">{{{ data.maxlength }}}</span>
        <span class="tc-remaining"> {{{ data.characters_remaining }}}</span>
    </span>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-formatted-price"><# if (data.customer_price_format_wrap_start) {#>
    {{{ data.customer_price_format_wrap_start }}}
    <# } #><?php echo esc_html($formatted_price); ?><# if (data.customer_price_format_wrap_end) {#>
    {{{ data.customer_price_format_wrap_end }}}
    <# } #></script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-formatted-sale-price"><# if (data.customer_price_format_wrap_start) {#>
    {{{ data.customer_price_format_wrap_start }}}
    <# } #><?php echo esc_html($formatted_sale_price); ?><# if (data.customer_price_format_wrap_end) {#>
    {{{ data.customer_price_format_wrap_end }}}
    <# } #></script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-upload-messages">
    <div class="header">
        <h3>{{{ data.title }}}</h3>
    </div>
    <div class="float_editbox" id="temp_for_floatbox_insert">
        <div class="tc-upload-messages">
            <div class="tc-upload-message">{{{ data.message }}}</div>
            <# for (var i in data.files) {
                if (data.files.hasOwnProperty(i)) {#>
                <div class="tc-upload-files">{{{ data.files[i] }}}</div>
                <# }
            }#>
        </div>
    </div>
    <div class="footer">
        <div class="inner">
            &nbsp;
        </div>
    </div>
</script>


第二个代码


<?php
$getProduct = new WC_Product(get_the_ID());
$getOptionTitle = get_option('woocommerce_paytrtaksit_title');
$getOptionMerchant = get_option('woocommerce_paytrtaksit_merchantid');
$getOptionToken = get_option('woocommerce_paytrtaksit_token');
$getOptionDescription = get_option('woocommerce_paytrtaksit_description');
$getOptionDescriptionBottom = get_option('woocommerce_paytrtaksit_description_bottom');
$getOptionMaxTaksit = get_option('woocommerce_paytrtaksit_maxTaksit');
$getOptionExtraTaksit = get_option('woocommerce_paytrtaksit_extraTaksit');
$getOptionTaxIncluded = get_option('woocommerce_paytrtaksit_taxIncluded');
if (version_compare(WOOCOMMERCE_VERSION,'3.0.0','<=')) {
    if ($getOptionTaxIncluded) {
        $getPrice = $getProduct->get_price_including_tax();
    } else {
        $getPrice = $getProduct->get_price_excluding_tax(); 
    }
} else {
    if ($getOptionTaxIncluded) {
        $getPrice = wc_get_price_including_tax($getProduct);
    } else {
        $getPrice = wc_get_price_excluding_tax($getProduct);
    }
}

if (empty($getOptionMaxTaksit)) {
    $getOptionMaxTaksit = 0;
}

wp_enqueue_style('paytr-style',plugin_dir_url(__FILE__) . "style.css",false,'1.0','all');

?>
 <script class="tm-hidden" type="text/template" id="tmpl-tc-cart-options-popup">
    <div class='header'>
        <h3>{{{ data.title }}}</h3>
    </div>
    <div id='{{{ data.id }}}' class='float_editbox'>{{{ data.html }}}</div>
    <div class='footer'>
        <div class='inner'>
            <span class='tm-button button button-secondary button-large floatbox-cancel'>{{{ data.close }}}</span>
        </div>
    </div>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-lightbox">
    <div class="tc-lightbox-wrap">
        <span class="tc-lightbox-button tcfa tcfa-search tc-transition tcinit"></span>
    </div>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-lightbox-zoom">
    <span class="tc-lightbox-button-close tcfa tcfa-times"></span>
    {{{ data.img }}}
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-final-totals">
    <dl class="tm-extra-product-options-totals tm-custom-price-totals">
        <# if (data.show_unit_price==true){ #><?php do_action( 'wc_epo_template_before_unit_price' ); ?>
        <dt class="tm-unit-price">{{{ data.unit_price }}}</dt>
        <dd class="tm-unit-price">
            <span class="price amount options">{{{ data.formatted_unit_price }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_unit_price' ); ?>
        <# } #>
        <# if (data.show_options_total==true){ #><?php do_action( 'wc_epo_template_before_option_total' ); ?>
        <dt class="tm-options-totals">{{{ data.options_total }}}</dt>
        <dd class="tm-options-totals">
            <span class="price amount options">{{{ data.formatted_options_total }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_option_total' ); ?>
        <# } #>
        <# if (data.show_fees_total==true){ #><?php do_action( 'wc_epo_template_before_fee_total' ); ?>
        <dt class="tm-fee-totals">{{{ data.fees_total }}}</dt>
        <dd class="tm-fee-totals">
            <span class="price amount fees">{{{ data.formatted_fees_total }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_fee_total' ); ?>
        <# } #>
        <# if (data.show_extra_fee==true){ #><?php do_action( 'wc_epo_template_before_extra_fee' ); ?>
        <dt class="tm-extra-fee">{{{ data.extra_fee }}}</dt>
        <dd class="tm-extra-fee">
            <span class="price amount options extra-fee">{{{ data.formatted_extra_fee }}}</span>
        </dd><?php do_action( 'wc_epo_template_after_extra_fee' ); ?>
        <# } #>
        <# if (data.show_final_total==true){ #><?php do_action( 'wc_epo_template_before_final_total' ); ?>
        <dt class="tm-final-totals">{{{ data.final_total }}}</dt>
        <dd class="tm-final-totals">
                <span class="price amount final">{{{ data.formatted_final_total }}}Kdv Hariç</span> 
        </dd><?php do_action( 'wc_epo_template_after_final_total' ); ?>
        <# } #>
        <?php do_action('wc_epo_after_js_final_totals'); ?>
    </dl>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-price">
    <span class="amount">{{{ data.price.price }}}</span>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-sale-price">
    <del>
        <span class="tc-original-price amount">{{{ data.price.original_price }}}</span>
    </del>
    <ins>
        <span class="amount">{{{ data.price.price }}}</span>
    </ins>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-section-pop-link">
    <div id="tm-section-pop-up" class="tm-extra-product-options flasho tm_wrapper tm-section-pop-up single tm-animated appear">
        <div class='header'><h3>{{{ data.title }}}</h3></div>
        <div class="float_editbox" id="temp_for_floatbox_insert"></div>
        <div class='footer'>
            <div class='inner'>
                <span class='tm-button button button-secondary button-large floatbox-cancel'>{{{ data.close }}}</span>
            </div>
        </div>
    </div>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-floating-box-nks">
    <# if (data.values.length) {#>
    {{{ data.html_before }}}
    <div class="tc-row tm-fb-labels">
        <span class="tc-cell tc-col-3 tm-fb-title">{{{ data.option_label }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-value">{{{ data.option_value }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-quantity">{{{ data.option__qty }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-price">{{{ data.option_lpric }}}</span>
    </div>
    <# for (var i = 0; i < data.values.length; i++) { #>
        <# if (data.values[i].label_show=='' || data.values[i].value_show=='') {#>
    <div class="tc-row">
            <# if (data.values[i].label_show=='') {#>
        <span class="tc-cell tc-col-3 tm-fb-title">{{{ data.values[i].title }}}</span>
            <# } #>
            <# if (data.values[i].value_show=='') {#>
        <span class="tc-cell tc-col-3 tm-fb-value">{{{ data.values[i].value }}}</span>
            <# } #>
        <span class="tc-cell tc-col-3 tm-fb-quantity">{{{ data.values[i].quantity }}}</span>
        <span class="tc-cell tc-col-3 tm-fb-price">{{{ data.values[i].price }}}</span>
    </div>
        <# } #>
    <# } #>
    {{{ data.html_after }}}
    {{{ data.totals }}}
    <# }#>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-floating-box">
    <# if (data.values.length) {#>
    {{{ data.html_before }}}
    <dl class="tm-fb">
        <# for (var i = 0; i < data.values.length; i++) { #>
            <# if (data.values[i].label_show=='') {#>
        <dt class="tm-fb-title">{{{ data.values[i].title }}}</dt>
            <# } #>
            <# if (data.values[i].value_show=='') {#>
        <dd class="tm-fb-value">{{{ data.values[i].value }}}</dd>
            <# } #>
        <# } #>
    </dl>
    {{{ data.html_after }}}
    {{{ data.totals }}}
    <# }#>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-chars-remanining">
    <span class="tc-chars">
        <span class="tc-chars-remanining">{{{ data.maxlength }}}</span>
        <span class="tc-remaining"> {{{ data.characters_remaining }}}</span>
    </span>
</script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-formatted-price"><# if (data.customer_price_format_wrap_start) {#>
    {{{ data.customer_price_format_wrap_start }}}
    <# } #><?php echo esc_html($formatted_price); ?><# if (data.customer_price_format_wrap_end) {#>
    {{{ data.customer_price_format_wrap_end }}}
    <# } #></script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-formatted-sale-price"><# if (data.customer_price_format_wrap_start) {#>
    {{{ data.customer_price_format_wrap_start }}}
    <# } #><?php echo esc_html($formatted_sale_price); ?><# if (data.customer_price_format_wrap_end) {#>
    {{{ data.customer_price_format_wrap_end }}}
    <# } #></script>
<script class="tm-hidden" type="text/template" id="tmpl-tc-upload-messages">
    <div class="header">
        <h3>{{{ data.title }}}</h3>
    </div>
    <div class="float_editbox" id="temp_for_floatbox_insert">
        <div class="tc-upload-messages">
            <div class="tc-upload-message">{{{ data.message }}}</div>
            <# for (var i in data.files) {
                if (data.files.hasOwnProperty(i)) {#>
                <div class="tc-upload-files">{{{ data.files[i] }}}</div>
                <# }
            }#>
        </div>
    </div>
    <div class="footer">
        <div class="inner">
            &nbsp;
        </div>
    </div>
</script>
<div>
    <h2><?php // echo !empty($getOptionTitle) ? esc_html($getOptionTitle) : 'Taksit Tablosu'; ?></h2>
    <?php if (!empty($getOptionDescription)) { ?>
        <div class="taksit-aciklama">
            <?php echo $getOptionDescription; ?>
        </div>
    <?php } ?>
    <div id="paytr_taksit_tablosu"></div>
    <?php if (!empty($getOptionDescriptionBottom)) { ?>
        <div class="taksit-aciklama">
            <?php echo $getOptionDescriptionBottom; ?>
        </div>
    <?php } ?>
</div>
<script src="https://www.paytr.com/odeme/taksit-tablosu/v2?token=<?php echo sanitize_text_field($getOptionToken); ?>&merchant_id=<?php echo sanitize_text_field($getOptionMerchant); ?>&amount=<?php echo sanitize_text_field($getPrice); ?>&taksit=<?php echo sanitize_text_field($getOptionMaxTaksit) ?>&tumu=<?php echo sanitize_text_field($getOptionExtraTaksit) ?>"></script>


解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...