Javascript 如何在我的woocommerce商店的分期付款计算插件中显示产品的动态总价?
我有一个woocommerce商店,还有一个产品选项插件和分期付款计算插件。产品选项插件会根据您的选择更改总价,但分期付款计算插件不会获取更改后的总价,以便再次动态计算 第一段代码属于产品选项插件,第二段代码属于分期付款计算插件。现在我如何显示分期付款计算插件计算的动态总价,这是由产品选项插件计算的 首先对第68行进行编码,以显示总价金额。my store上的示例是: 您可以在Taksit Seçenekleri选项卡下看到分期付款计算插件的结果Javascript 如何在我的woocommerce商店的分期付款计算插件中显示产品的动态总价?,javascript,php,woocommerce,Javascript,Php,Woocommerce,我有一个woocommerce商店,还有一个产品选项插件和分期付款计算插件。产品选项插件会根据您的选择更改总价,但分期付款计算插件不会获取更改后的总价,以便再次动态计算 第一段代码属于产品选项插件,第二段代码属于分期付款计算插件。现在我如何显示分期付款计算插件计算的动态总价,这是由产品选项插件计算的 首先对第68行进行编码,以显示总价金额。my store上的示例是: 您可以在Taksit Seçenekleri选项卡下看到分期付款计算插件的结果 <?php /** * The jav
<?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">
</div>
</div>
</script>
{{{data.title}}}
{{{data.html}}}
{{{data.close}}}
{{{data.img}}}
{{{data.unit_price}}}
{{{data.formatted{u unit{u price}}}
{{{data.options_total}}}
{{{data.formatted_options_total}}
{{{data.fees_total}}
{{{data.formatted{u fees{u total}}
{{{data.extra_fee}}}
{{{data.formatted{u extra{u fee}}}
{{{data.final{u total}}}
第68行{{data.formatted_final_total}}
{{{data.price.price}}}
{{{data.price.original_price}}}
{{{data.price.price}}}
{{{data.title}}}
{{{data.close}}}
{{{data.html_before}}}
{{{data.option_label}}}
{{{data.option_value}}}
{{{data.option}}
{{{data.option_lpric}}}
{{{data.values[i].title}}
{{{data.values[i].value}}
{{{data.values[i].quantity}}
{{{data.values[i].price}}
{{{data.html{u after}}}
{{{data.totals}}}
{{{data.html_before}}}
{{{data.values[i].title}}
{{{data.values[i].value}}
{{{data.html{u after}}}
{{{data.totals}}}
{{{data.maxlength}}}
{{{data.characters_remaining}}}
{{{data.customer\u price\u format\u wrap\u start}}
{{{data.customer\u price\u format\u wrap\u end}}
{{{data.customer\u price\u format\u wrap\u start}}
{{{data.customer\u price\u format\u wrap\u end}}
{{{data.title}}}
{{{data.message}}}
{{{data.files[i]}}}
第二代码
<?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">
</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>
{{{data.title}}}
{{{data.html}}}
{{{data.close}}}
{{{data.img}}}
{{{data.unit_price}}}
{{{data.formatted{u unit{u price}}}
{{{data.options_total}}}
{{{data.formatted_options_total}}
{{{data.fees_total}}
{{{data.formatted{u fees{u total}}
{{{data.extra_fee}}}
{{{data.formatted{u extra{u fee}}}
{{{data.final{u total}}}
{{{data.formatted_final_total}}}Kdv Hariç
{{{data.price.price}}}
{{{data.price.original_price}}}
{{{data.price.price}}}
{{{data.title}}}
{{{data.close}}}
{{{data.html_before}}}
{{{data.option_label}}}
{{{data.option_value}}}
{{{data.option}}
{{{data.option_lpric}}}
{{{data.values[i].title}}
{{{data.values[i].value}}
{{{data.values[i].quantity}}
{{{data.values[i].price}}
{{{data.html{u after}}}
{{{data.totals}}}
{{{data.html_before}}}
{{{data.values[i].title}}
{{{data.values[i].value}}
{{{data.html{u after}}}
{{{data.totals}}}
{{{data.maxlength}}}
{{{data.characters_remaining}}}
{{{data.customer\u price\u format\u wrap\u start}}
{{{data.customer\u price\u format\u wrap\u end}}
{{{data.customer\u price\u format\u wrap\u start}}
{{{data.customer\u price\u format\u wrap\u end}}
{{{data.title}}}
{{{data.message}}}
{{{data.files[i]}}}
@你能帮我吗?谢谢