我有一个电子商务应用程序,几天前运行良好。在我更新 wordpress 和 woocommerce 插件后,该应用程序突然停止工作。
\n我认为这与我使用的插件(mstore app-mobile)有关,但不幸的是无法更新此插件。
\n错误发生在此 updateCartQty 函数上。我的猜测是关于函数参数的一些事情。
\npublic function updateCartQty()\n{ \n $cart_item_key = $_REQUEST[\'key\'];\n $qty = (int)$_REQUEST[\'quantity\'];\n\n global $woocommerce;\n $woocommerce->cart->set_quantity($cart_item_key, $qty); \n $this->cart(); \n}\nRun Code Online (Sandbox Code Playgroud)\n这是日志文件:
\n2021-02-22T23:43:48+00:00 CRITICAL Uncaught Error: Call to a member function get_tax_class() on null in /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php:225\nStack trace:\n#0 /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(651): WC_Cart_Totals->get_items_from_cart()\n#1 /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(143): WC_Cart_Totals->calculate_item_totals()\n#2 /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(134): WC_Cart_Totals->calculate()\n#3 /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart.php(1369): WC_Cart_Totals->__construct()\n#4 /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart.php(1328): WC_Cart->calculate_totals()\n#5 /var/www/html/ecommerce/htdocs/wp-content/plugins/mstoreapp-mobile-app-multivendor/public/class-mstoreapp-mobile-app-public.php(1277): WC_Cart->set_quantity()\n#6 , em /var/www/html/ecommerce/htdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php, na linha 225\nRun Code Online (Sandbox Code Playgroud)\n系统信息:
\nWC Version: 5.0.0\nREST API Version: \xe2\x9c\x94 5.0.0\nWC Blocks Version: \xe2\x9c\x94 4.0.0\nAction …Run Code Online (Sandbox Code Playgroud) 基于“在woocommerce的管理订单列表顶部添加一个按钮”答案代码,我能够在woocommerce管理订单列表上添加一个自定义按钮。
这是代码(稍微定制):
add_action( 'manage_posts_extra_tablenav', 'admin_order_list_top_bar_button', 20, 1 );
function admin_order_list_top_bar_button( $which ) {
global $typenow;
if ( 'shop_order' === $typenow && 'top' === $which ) {
?>
<div class="alignleft actions custom">
<button type="submit" name="custom_" style="height:32px;" class="button" value=""><?php
echo __( 'Import Couriers', 'woocommerce' ); ?></button>
</div>
<?php
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当单击此自定义按钮时,我需要运行以下函数:
function update_shipping_couriers_meta_field() {
$dir = __DIR__;
$couriers = file( $dir . '/import-couriers.csv', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
$count = count(couriers);
$i = 1;
do {
if …Run Code Online (Sandbox Code Playgroud) 我正在尝试重新设计 woocommerce 单一产品页面,而不是显示变体选项的下拉菜单,我希望将它们放置在单独的 div 中并并排显示在弹性框中。我不明白是什么部分使数据采用“下拉列表”形式?
我想要实现的目标的说明:
这是 html 部分(取自includes文件夹内的wc-template-functions.php),我需要将每个变体插入一个单独的div中,而不是选择和选项标签。我真的需要这个。有什么帮助吗?
这是我在woocommerce ->includes -> wc-template-functions.php内的尝试,在函数 wc_dropdown_variation_attribute_options内。它显示了变化,但它们不可点击,也无法提取数据来选择并转发添加到购物车/立即购买事件:
function wc_dropdown_variation_attribute_options( $args = array() ) {
$args = wp_parse_args(
apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ),
array(
'options' => false,
'attribute' => false,
'product' => false,
'selected' => false,
'name' => '',
'id' => '',
'class' => '',
)
);
// Get selected value.
if ( false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product ) {
$selected_key = 'attribute_' . sanitize_title( $args['attribute'] ); …Run Code Online (Sandbox Code Playgroud) 我想在用户创建并保存产品数据后通过肥皂客户端将 woocommerce 产品数据发送到邮政公司的网络服务。所以我需要一个在用户创建产品后触发的钩子。我搜索了很多并找到了一些 wordpress 和 woocommerce 钩子,但它们都没有完成我的工作。发送日期后,Web 服务返回一个应设置为产品 SKU 的 ID。听到的是我的函数代码:(参数来自 save_post_product 挂钩)
function productPublished ($ID , $post , $update){
$product = wc_get_product( $post->ID);
$user = get_option ('myUsername');
$pass = get_option ('myPassword');
$name = $product->get_name();
$price = $product->get_regular_price();
$weight = $product->get_weight() * 1000;
$count = $product->get_stock_quantity();
$description = $product->get_short_description();
$result = $client -> AddStuff ([
'username' => $user,
'password' => $pass,
'name' => $name,
'price' => $price,
'weight' => $weight,
'count' => $count,
'description' => $description,
'percentDiscount' => 0
]); …Run Code Online (Sandbox Code Playgroud) 我想显示 woocommerce 中不同角色的产品价格。为了这个目标,我通过输入字段在产品的后元中设置了一个带有价格元值的元键。然后我使用以下代码来过滤该产品的显示价格以获得所需的角色。角色是customer_2
例如:产品_A 的正常价格为 200 美元,客户_2 显示为 150 美元,产品_B 的正常价格为 350 美元,客户_2 显示为 200 美元,依此类推...
function custom_price($price, $product){
$product_co_price = get_post_meta($product->ID, '_co_price');
$user = wp_get_current_user();
if($product_co_price){
if(in_array('customer_2', (array) $user->roles)){
$price = $product_co_price;
}
}
return $price;}
add_filter('woocommerce_product_get_price', 'custom_price', 10, 2);
add_filter('woocommerce_product_variation_get_price', 'custom_price', 10, 2 );
add_filter( 'woocommerce_product_get_regular_price', 'custom_price', 10, 2 );
add_filter( 'woocommerce_product_get_sale_price', 'custom_price', 10, 2 );
Run Code Online (Sandbox Code Playgroud)
元键中的“_co_price”存储价格的元值。
但什么也没发生!
我需要在结账后发送这两封电子邮件。
1.- Woocommerce 自动电子邮件(汇总订单、王子、总价等)。
2.- 包含附加信息的电子邮件。
我一直在寻找,但无法通过 WooCommerce 插件做到这一点,而且我无法使用 Shopmagic 等其他插件,所以......它必须使用代码。
经过长时间的搜索,我认为可能是这样的。
(状态控制的顺序是processing和否completed,因为我在Stripe和Stripe中使用测试模式进行测试,在测试模式下,订单被定义为“处理”状态,而不是completed。
我的文件中现在的内容functions.php是:
$order = new WC_Order( $order_id );
function order_processing( $order_id ) {
$order = new WC_Order( $order_id );
$to_email = $order["billing_address"];
$headers = 'From: Your Name <alexiglesiasvortex@gmail.com>' . "\r\n";
wp_mail($to_email, 'subject', '<h1>This is a test for my new pending email.</h1><p>Agree, this is a test</p>', $headers );
}
add_action( 'woocommerce_payment_processing', 'order_processing' );
Run Code Online (Sandbox Code Playgroud)
目前,这不起作用......我没有收到任何错误并且结帐正确结束,但没有新电子邮件到达我的收件箱。
我需要帮助,伙计们,有人可以帮助我吗?非常感谢您,祝您星期一愉快!
我正在寻找显示 6 个最畅销产品类别的方法。这就是我现在得到的:
$termsprent = get_terms(
array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
'numberposts' => 4,
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'order' => 'desc',
)
);
Run Code Online (Sandbox Code Playgroud)
有谁知道如何修改它以显示最畅销的产品类别?