【php – 如何订购具有最多产品的类别】教程文章相关的互联网学习教程文章

php – 添加产品时,如何在woocommerce产品页面中创建自定义字段值(必填)【代码】

我在woocommerce的添加产品页面中添加了自定义文本框字段.现在我想要它(必修).我通过传递参数“required”=> true来尝试它.但它不起作用.请看下面的代码woocommerce_wp_text_input(array('id' => 'special_price','label' => __( 'Wholesaler Price *', 'woocommerce' ),'placeholder' => '','desc_tip' => 'true','required' => 'true','description' => __( 'Enter wholesaler price here.', 'woocommerce' )) );但它不是强制使用...

使用Shopify API在PHP中创建产品【代码】

非常感谢您的解决方案.我正在使用Shopify API和PHP CURL POST方法来创建产品.以下是代码和输出.$products_array = array("product"=>array('title'=>'',"title"=> "Burton Custom Freestlye 151","body_html"=> "<strong>Good snowboard!</strong>","vendor"=> "Burton","product_type"=> "Snowboard","published"=> false ,"variants"=>array(array("sku"=>"t_009","price"=>20.00,"grams"=>200,"taxable"=>false,))) ); echo jso...

php – 如何根据用户角色隐藏具有给定类别的WooCommerce产品【代码】

我有一个客户端有以下问题: 我需要能够将他们的WooCommerce WordPress网站分为两类.如果用户以“Wholeseller”身份登录,则只会从数据库中提取“Wholesale”类别中的产品. 但是,如果用户未登录或登录但不是“Wholeseller”,则只有没有“Wholesale”类别的产品才会从数据库中删除. 我想我会在主题的functions.php文件中添加这样的东西:add_filter("some_woocommerce_hook", "wholeseller_filter");function wholeseller_filter() {...

php – 如何从woocommerce中的购物车页面获取特定的产品数量【代码】

使用此代码:foreach ( WC()->cart->get_cart() as $cart_item ) { $quantity = $cart_item['quantity'];echo $quantity; }我可以获得购物车中添加的所有产品的数量,但我需要特定产品.解决方法:你应该试试这个:// Set here your product ID $targeted_id = 24;foreach ( WC()->cart->get_cart() as $cart_item ) { if($cart_item['product_id'] == $targeted_id ){$qty = $cart_item['quantity'];break; // stop the loop if p...

php – 仅显示Woocommerce Recent Products短代码中的“库存”产品【代码】

在首页上使用Woocommerce Recent Products短代码时,我需要排除显示缺货商品.[recent_products]是否有可能创建一个像hide_outofstock =“true”这样的规则或类似的东西来阻止缺货产品展示? 我已经在网上寻找关于如何处理这个问题的想法,而我根本就没有编码器,但通常我能够坦率地解决这个问题.但是,现在我很难过.所有和任何帮助将不胜感激. >我不能通过WooCommerce设置页面隐藏所有缺货产品,因为它们需要在网站的其他区域中可见.>使...

php – 可变产品属性:自定义每个显示的单选按钮文本值【代码】

在WooCommerce中,我使用WC Variations Radio Buttons插件(8manos)来替换典型的下拉选择器和Radio Buttons. 我已将以下代码添加到我的子主题function.php中:// Display the product variation price inside the variations dropdown. add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );function display_price_in_variation_option_name( $term ) {global $wpdb, $product;if ( empty...

php – 获取与WooCommerce中的默认属性值相关的产品变化【代码】

我想在我的前端模板文件中显示默认的产品属性表单值和常规价格. 下面的var_dump显示了数组中的选项.我需要获取[default_attributes]值.<?php global $product;echo var_dump( $product ); // Need to get the [default_attributes] values?>解决方法:要获取变量产品的默认属性,可以使用WC_Product方法get_default_attributes():<?php global $product;if( $product->is_type('variable') ){$default_attributes = $product->get_d...

php – 根据WooCommerce中的产品自定义字段和产品类别隐藏添加到购物车按钮【代码】

我想在woocommerce产品页面后端添加一个自定义复选框,隐藏前端的“添加到购物车”按钮.我不想完全删除购买该商品的能力(仍然希望能够使用直接添加到购物车网址将商品添加到购物车并购买)所以我不想使用add_filter(‘ woocommerce_is_purchasable’,’my_woocommerce_is_purchasable’,10,2);或类似的. 我目前取得的成就是: 添加自定义复选框// Display Checkbox add_action('woocommerce_product_options_general_product_data', ...

php – Magento产品系列仅获取某些类别的产品【代码】

我正在尝试获得仅具有某些类别的销售价格的产品列表.现在我正在尝试使用产品集合来获取这些数据.我不确定如何仅限制特定类别的集合.这是我到目前为止:$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('status', 1)->addAttributeToFilter('visibility', 4)->addAttributeToFilter('special_price', array('neq' => ""))->addAttributeToFilter('discontinued'...

php – magento 1.5产品评论存储在哪里?

在我的magento 1.5网上商店中,我重新创建了一些产品,因为它似乎是将可配置产品转换为简单产品的最简单方法.无论如何,现在我想将评论转移到新产品,但我无法在数据库中找到它们.有谁知道它们存储在哪里,以便我可以将它们移动到正确的产品? -谢谢解决方法:您感兴趣的表格是评论.此表包含评论本身与产品之间的关系.查看表有一个名为entity_pk_value的列,该列引用正在审阅的产品的主键. 将entity_pk_value列中的值替换为新的产品ID,并且...

php – 如何检测用户是否已订阅了Memberpress产品【代码】

如何检测用户是否已购买会员产品. 我正在搜索这样的东西:if(have_subscription){ //code to add button }else{// code to add something else }提前致谢!解决方法:使用MemberPress的内置功能,这应该是非常直接的:if(current_user_can('memberpress_authorized')) {// Do authorized only stuff here } else {// Do unauthorized stuff here }MemberPress还为每个MemberPress会员添加功能,因此您也可以执行以下操作:if(current_...

php – Magento.按位置对产品集合进行排序【代码】

我有产品系列.$_products = Mage::getModel('catalog/product')->getCollection();在目录中的管理面板 – >管理类别 – >类别产品我有每个产品的位置.我如何按位置对$_products进行排序?解决方法:如果要按类别$category_id中的位置对产品进行排序.你可以使用以下//Load the category model$category = Mage::getModel('catalog/category')->load($category_id)->getProductCollection()->addAttributeToSort('position', 'ASC');$...

php – 在WooCommerce电子邮件模板中获取产品名称和描述【代码】

我想在WooCommerce电子邮件模板中发送电子邮件时获取产品描述和产品名称. 我能够获得产品ID $order_id = trim(str_replace(‘#’,”,$order-> get_items()));使用此代码 但是当我试图获得它的描述和产品名称时,我无法做同样的事情. 我的代码:$order = new WC_Order($order_id);foreach($order->get_items() as $item){$product_description = get_post($item['product_id'])->post_content;}我怎样才能使它工作? 谢谢 我在functi...

php – Drupal / Ubercart在结账时检查购物车中是否有某种产品【代码】

在某些情况下,我有一个特定产品需要放入购物车.我一直在查看Ubercart api文档,我没有看到任何钩子,这些钩子在结账前是否存在某个项目是显而易见的. 每当添加第一个项目时,我都可以使用hook_add_to_cart挂钩添加特殊项目,但我担心访问者可能会删除该项目,然后在没有所需项目的情况下完成购买. 有什么建议如何确保特殊项目在结帐时在购物车中?解决方法:你可以有一个模块并运行如下:function mymodule_init() {if (preg_match('/che...

php – 如何在Javascript中计算多个产品的总量?价值来自AJAX【代码】

$.ajax({type: "POST",url: 'ajax_subtotal.php',data: listing_id=listId,dataType:'json',success: function(data){if(data['result']=='success'){alert(data['pricing']);} }data [‘pricing’]给我一个产品的价格.如果产品数量发生变化,该功能正在调用.那么,如何同时计算多个产品的总价?解决方法: First i store all the value in to the hidden field..<input type="hidden" name="NumberOfProperty[]" id="NumberOfPropert...