product

Woocommerce - Retrieve shipping class

我是研究僧i 提交于 2019-12-02 19:16:48
问题 I use following code on external script to retrieve all products (simple and variable): $args = array( 'post_type' => array('product', 'product_variation'), 'numberposts' => -1, 'post_status' => 'publish', ); $shop_products = get_posts( $args ); foreach ($shop_products as $item) { echo $item->ID.": shipping class is -> ".$item->get_shipping_class()."<br>"; } I need to create a list of product with their own shipping class, but it doesn't works. It shows me the error " Call to undefined method

How to display tags product in view.phtml of Magento

試著忘記壹切 提交于 2019-12-02 17:50:43
问题 I created new theme and use them for creating product. In view page, I don't see product tags. I review view.pthml in default and know that the tags in "echo $this->getChildHtml('product_additional_data') " , my view.phtml has it too but why it don't display tags plz, any advice 回答1: This is what I did after about 4 hours of research. <?php // instantiate the tags class for products $_tags = new Mage_Tag_Block_Product_List(); ?> <ul class="product-tags"> <?php foreach($_tags->getTags() as

What is the difference between isSaleable() and isAvailable()?

怎甘沉沦 提交于 2019-12-02 16:07:02
I'm working on the display of the stock availability on the (individual) product page of my Magento theme, and there's something I don't completely understand about this. I see two methods being used in the templates to check whether a product is available for sale: Mage_Catalog_Model_Product::isAvailable() Mage_Catalog_Model_Product::isSaleable() My own findings: I see that isSalable() (which in turn is called by isSaleable() ) calls isAvailable() but also dispatches two events ( catalog_product_is_salable_before and catalog_product_is_salable_after ). On the fronted I've noticed that in

Custom field validation in Woocommerce single product pages [closed]

时光总嘲笑我的痴心妄想 提交于 2019-12-02 15:56:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I would like to create a Woocommerce product with an additional text input field which checks if the value entered is unique to that field otherwise outputs a message. In other words if I enter "dave" and "dave" has been submitted by a different user then I cant proceed with the

Show a CATEGORY and its products on Homepage, Magento1.9

别说谁变了你拦得住时间么 提交于 2019-12-02 15:39:18
问题 I want to show a Category with its Products on homepage. Magento has built in option to show New Products on homepage and I have no idea about how to show different categories on homepage. For example I have created a category and I want to show the products in this category on homepage as below: Featured Products Product1 Product2 Product3 I have tried below code (from previous posts) {{block type="catalog/product_new" name="home.catalog.product.list" alias="products_homepage" template=

Magento programmatically remove product images

喜夏-厌秋 提交于 2019-12-02 15:16:25
This must be a such a simple programming task that I absolutely cannot find any information about it on the net. Basically, I'm trying to DELETE product images. I want to delete all images from a product's media gallery. Can I do this without wading through a million lines of code for such a simple task? Please note that I've already tried this: $attributes = $product->getTypeInstance()->getSetAttributes(); if (isset($attributes['media_gallery'])) { $gallery = $attributes['media_gallery']; $galleryData = $product->getMediaGallery();//this returns NULL foreach($galleryData['images'] as $image){

Disable other product categories for a cart item from specific category in Woocommerce

◇◆丶佛笑我妖孽 提交于 2019-12-02 13:01:15
问题 I'm developing a webshop, with different aspects, the first is a regular shop, and the second is a night beer service. i've searched but can't find what i am looking for; First the night beer service is a specific category that shouldn't be ordered with the regular items (if category 'beerservice' is in the cart, disable all other categories to be added to the cart). This option also needs to work vice-versa (the other wat around), so if a regular item is added to the cart, the category of

Allow backorders and notify customer for specific product categories in Woocommerce

萝らか妹 提交于 2019-12-02 12:34:55
问题 IN woocommerce I'm trying to add some code in functions.php to allow backorder for specific product categories. But the code doesn't works. How can I allow backorders and notify customer for specific product categories in Woocommerce? 回答1: Updated Try the following (where you will set your product category(ies) in the array for each function) : add_filter( 'woocommerce_product_is_in_stock', 'filter_product_is_in_stock', 10, 2 ); function filter_product_is_in_stock( $is_in_stock, $product ){ /

Conditionally set cart item prices for specific products in WooCommerce 3

社会主义新天地 提交于 2019-12-02 11:54:47
In WooCommerce I am using some code from this answer: Set WooCommerce cart item price to zero if the product has already been bought It works great with one product, but I would like to make it work with several products . So the code below, for a specific product, change the cart item price to $0.00 if customer has already purchased and if not the price is set to $100 (for the first purchase) : add_action( 'woocommerce_before_calculate_totals', 'conditionally_change_cart_items_price', 10, 1 ); function conditionally_change_cart_items_price( $cart_object ) { if ( is_admin() && ! defined(

Set only specific products sale price programmatically in WooCommerce 3

守給你的承諾、 提交于 2019-12-02 10:39:44
问题 I would like to Set product sale price programmatically in WooCommerce 3 but only for specific products Ids. Is it possible and how can I target only specific products using this thread code? I haven't be able to make it work for specific products only. Any help is appreciated. 回答1: To Set only specific product sale price (the products IDs are defined in the 1st function) , try this: // HERE below in the array set your specific product IDs function specific_product_ids(){ return array(37, 43,