3
別の入力ボックスにサイドバーに表示するようにプラグインで製品重量を取得しようとしています。しかし、私は製品の重量を得ることができません。WooCommerceで製品重量を取得することができません
私のコードを見て、WooCommerce製品から製品重量を得るために私を助けてください:
<?php
/**
* Plugin Name: Calculator
* Plugin URI: http://wordpress.org/
* Description: Calculate
* Version: 1.0.0
* Author: wtm
* Author URI: http://wtynet.com
*/
if (!defined('ABSPATH')) exit; // Exit if accessed directly
if (!in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) return; // Check if WooCommerce is active
add_action('woocommerce_product_meta_end', 'showtest', 10);
function showtest(){
$prweight = WC_Product::get_weight();
echo "<div style='border: 2px solid #43515f; padding: 10px; text-align:center;'>";
your_css_and_js();
echo "<input id= 'prweight' type='text' value='".$prweight."'>";
echo "</div>";
}
function your_css_and_js() {
wp_register_style('your_css_and_js', plugins_url('css/style.css',__FILE__));
wp_enqueue_style('your_css_and_js');
wp_register_script('your_css_and_js', plugins_url('js/script.js',__FILE__));
wp_enqueue_script('your_css_and_js');
}
?>
感謝。
本当にありがとう、私の問題を修正しました:) – wind