草庐IT

woocommerce_before_cart

全部标签

php - Woocommerce wp_query 按 ID 获取订单

我正在尝试生成订单数据的简单输出。第一步是WP_QUery(可能)所以我写了这段代码;$args=array('post_type'=>'shop_order','posts_per_page'=>-1,'post_status'=>'any',//'p'=>$post_id,);$order_query=newWP_Query($args);while($order_query->have_posts()):$order_query->the_post();echothe_ID();echo':';the_title();echo'';endwhile;它要求产品列出所有订单,如果我

php - 用 PHP 更新 WooCommerce 产品的价格

我正在尝试更改我的WooCommerce网站上各种产品的价格,但我遇到了问题。当我运行脚本时,如果我在数据库和目标中更改正确,网页前端仍然显示为错误的价格,甚至有些价格显示为“免费”。最奇怪的是,如果我看到价格正确,则输入产品版本。我给你代码示例:$stock=$value['stock'];$regular_price=$value['rates']['2']['rate_pvp'];update_post_meta($post_id,'_regular_price',$regular_price);update_post_meta($post_id,'_price',$regula

php - 在 WooCommerce 订阅中获取用户 ID

我正在使用WooCommerce订阅插件,我正在尝试获取给定wc_subscription的客户或用户ID。这是我一直在使用但失败的代码:add_action('woocommerce_scheduled_subscription_trial_end','registration_trial_expired',100);functionregistration_trial_expired($wc_subscription){mail("example@gmail.com","Expired","Someone'sorderhasexpired");$userid=$wc_subscri

php - 如何在 WooCommerce 中为自定义产品类型启用价格和库存

我在我的WooCommerce应用程序中创建了一个自定义产品类型functionregister_variable_bulk_product_type(){classWC_Product_Variable_bulkextendsWC_Product_Simple{publicfunction__construct($product){$this->product_type='variable_bulk';parent::__construct($product);}}}add_action('init','register_variable_bulk_product_type');fu

php - WooCommerce - 确定当前单个产品页面的产品类别

在我的header.php中,我想根据页面的类别添加标题。我当前的代码如下所示:ID)){echo"musicintheworldofnoise";}elseif(is_category('marathi')||has_category('marathi',$post->ID)){echo"क्षितिजजसेदिसते";}elseif(is_category('happenings')||has_category('happenings',$post->ID)){echo"Happenings";}elseif(is_product()&&is_product_category('

php - WooCommerce:根据单个商品数量添加折扣

在我的WooCommerce网站上,我有一些价格相同的产品80美元。我想按产品数量添加折扣。逻辑是这样的:if(ProductsQuantityis2){//theoriginalproductpricechangefrom80$to75$each.}if(ProductsQuantityis3ormore){//theoriginalproductpricechangefrom80$to70$each.}例如,ifacustomerpick2products,theoriginalpricewillbe(80$x2)=>160$.Butafterthediscount,itwillb

php - 在 WooCommerce 可变产品中的每个属性值旁边显示库存状态

我想在我的商店中实现类似这样的东西:我有这个代码,但它在每个变体旁边显示数量。functionget_stock_variations_from_product(){global$product;$variations=$product->get_available_variations();foreach($variationsas$variation){$variation_id=$variation['variation_id'];$variation_obj=newWC_Product_variation($variation_id);$stock=$variation_obj

php - WooCommerce 3.0 : can't find hook which corresponds to an admin created backend order

按照这个post的思路,当管理员使用我的支付网关通过管理面板创建订单时,我正在尝试连接到我自己的自定义支付网关。我添加了以下代码:add_action('woocommerce_process_shop_order_meta',array($this,'process_offline_order'));add_action('woocommerce_admin_order_actions_end',array($this,'process_offline_order2'));add_action('woocommerce_save_post_shop_order',array($thi

php - 根据 woocommerce 类别更改同一产品的默认变体值

我正在研究一种根据他所属的类别显示同一产品的默认变体值的方法。例如,我出售一张带有蓝色和红色选项的卡片。当用户进入类别ONE时,我希望默认值为蓝色。如果他属于第二类,则该值为红色。我找到了一个钩子(Hook)woocommerce_product_default_attributes,但我不知道如何使用它。注意:即使您的产品属于两个类别,woocommerce似乎也只能识别每个产品的一个类别。示例(编辑):我有一个产品P.产品P分为两类:Cat1&Cat2.此外,产品P有两个变量:Blue&Red当用户来到时Cat1,我希望默认值为Blue。如果他来Cat2,该值将为Red.@Loic

php - 使 Woocommerce 自定义结帐字段不可编辑

我在woocommerce结帐页面上添加了一个自定义字段,该字段由URL填充,但我正在努力寻找一种方法使该field不可编辑。我在function.php中添加了以下代码://Addcustomfieldfunctioncustom_woocommerce_checkout_fields($checkout_fields=array()){$checkout_fields['order']['imei']=array('type'=>'text','class'=>array('my-field-classform-row-wide'),'label'=>__('IMEI'),'pla