目前,我正在开发 WooCommerce (5.2.2) 项目。我的客户希望在后端(不适用于客户)为预付款创建一个自定义输入字段,以便当我的客户收到客户的预付款(交货目的)时,他们可以手动添加并从后端订购总计自动调整。因此,我编写了代码并在帖子元表中创建了一个自定义字段,并使用该元表值来计算总订单,它可以工作,但我必须刷新两次才能获取订单的总新值。这是我的代码并告诉我如何修复它 -
add_action( 'manage_shop_order_posts_custom_column' , array(&$this,'add_custom_column_content'), 11, 2 );
add_action( 'woocommerce_admin_order_totals_after_discount', array(&$this, 'vp_add_sub_total'), 10, 1);
add_action( 'woocommerce_process_shop_order_meta', array(&$this, 'save_order_custom_field_meta_data'), 12, 2 );
// Output a custom editable field in backend edit order pages under general section
function editable_order_custom_field( $order ){
// Get "Delivery Type" from meta data (not item meta data)
$updated_advance_payment = $order->get_meta('_advance_payment');
// Replace "Delivery Type" value by the meta data if it exist
$advancePayment = $updated_advance_payment ? $updated_advance_payment : ( isset($item_value) ? $item_value : …Run Code Online (Sandbox Code Playgroud) 如何检测右上角左下角区域的JavaScript?我有4个箭头用于滑块,但我只想在鼠标悬停在特定区域时显示.
$('.container').mousemove(function (e) {
if (e.clientY < $('.container').height() / 2) {
console.log('top');
} else {
console.log('bottom');
}
if (e.client X < $('.container').width() / 2) {
console.log('left');
} else {
console.log('right');
}
});
Run Code Online (Sandbox Code Playgroud) 我正在使用 WordPress / WooCommerce
\n我的要求是当客户在CART页面时,我想每5秒刷新一次CART ,而不需要页面加载。
\n例如:如果客户已将 1 个产品添加到购物车,价格为 \xe2\x82\xb98.00
\n随后,管理员将产品的价格从 \xe2\x82\xb98.00 更改为 \xe2\x82\xb910.00
\n如何在不刷新页面的情况下显示最新价格?
\n我正在使用这段代码,但不起作用
\n(function( $ ) {\n 'use strict';\n\n jQuery( document ).ready(function($) {\n function refresh_fragments() {\n console.log('fragments refreshed!');\n $( document.body ).trigger( 'wc_fragments_refreshed' );\n }\n refresh_fragments();\n setInterval(refresh_fragments, 5000);\n });\n\n})(jQuery);\nRun Code Online (Sandbox Code Playgroud)\n 我使用这个钩子在商店页面上显示变化。但是,选择变量后,产品图像不会改变。它适用于单个产品页面。刚接触 WordPress 和 PHP,我认为 woocommerce 挂钩的工作方式就像“复制和粘贴”。为什么它不适用于商店页面?它如何适用于商店页面?
add_action( 'woocommerce_before_shop_loop', 'show_production_variations_on_shop_page' );
function show_production_variations_on_shop_page() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 30 );
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Google Map API V3,我注意到这里有很多标记,即使我不需要它们。所以我想隐藏除我以外的所有其他位置或不丢失我的位置标题。
下面是我的代码
HTML
<div id="map"></div>
Run Code Online (Sandbox Code Playgroud)
Javascript
var map;
function initMap() {
var myLocation = { lat: 52.5750833, lng: -0.2412917 };
map = new google.maps.Map( document.getElementById('map'), {
center: myLocation,
zoom: 19,
mapTypeControl: false
});
}
Run Code Online (Sandbox Code Playgroud)
我已经使用了这个代码。这对我有帮助,但它也删除了名为“皇家广场”的位置标题
var noPoi = [
{
featureType: "poi",
elementType: "labels",
stylers: [
{
visibility: "off"
}
]
}
];
map.setOptions({styles: noPoi});
Run Code Online (Sandbox Code Playgroud)