product

Change Magento product status in different store views

拜拜、爱过 提交于 2019-12-07 07:27:32
问题 I have a Magento Multi-Store installation. I have a product that must be enabled in shopA and disabled in shopB If i select the tab "Websites" there is an alert "Items that you don't want to show in the catalog or search results should have status 'Disabled' in the desired store." so probably it is possible? The default value status of the product is "enabled" Then i select the store view of shopB and disabled the product status. Now the status of the product in shopA is also disabled. Is it

Woocommerce global product (multisite)

丶灬走出姿态 提交于 2019-12-07 07:13:02
问题 I set in wordpress the property multisite and activated woocommerce on my network. My network is formed by a primary site and a subsite. I would like to see from the subsite see the products on the primary site, and products, attributes and categories in the admin bar corresponding products. Does anyone know how to do? 回答1: Yes, you can do it with the WooCommerce MultiStore plugin. These are a few of the plugin's main features: Any Product can be replicated across network, making it available

Get the product variations attributes values term ID and name

北城余情 提交于 2019-12-07 02:39:58
问题 In WooCommerce, I'm using $product->get_variation_attributes() to get the variations attributes for a product. This function returns an array with the names without the ID's. Like this: [pa_color-shirt] => Array ( [0] => red [7] => grey [14] => yellow ) [pa_color-sweater] => Array ( [0] => red [1] => green [2] => blue [3] => grey [4] => yellow [5] => pink [6] => dark-blue ) For the AJAX shop I'm creating I also need the ID's from the variations. So I can append the Id's and the names to the

Change Add To Cart button text based on Woocommerce parent product categories

风格不统一 提交于 2019-12-06 18:52:26
I am using the following code to change the wording on a Woo product add to cart button based on its parent category. The code works but has the following bug. If one of the parent categories is empty (i.e. does not have any sub cats) then the code no longer works. So the current code must be missing a string to check if parent category is empty or not but I do not know how to code that. This is the snippet I am running: // Utility function to get the childs array from all parent categories function get_the_childs( $product_category ){ $taxonomy = 'product_cat'; $parent = get_term_by( 'slug',

Opencart: How to relate product options (like size and color)?

三世轮回 提交于 2019-12-06 16:49:31
I'm using opencart version 1.5.5.1 for our website. I need to add more than one option for products. For example: I need to show shirts of sizes- Large/Medium/Small and colors White/Black/Blue/Red/Green etc. By default opencart allows us to add separate quantities for each color and size. How can I mention that we've 5 Large Shirts of Blue Color, 3 Medium Shirts of White Color etc. ? Please help. Thanks in Advance! I guess this would only be possible if You create an options for size x color combinations only. Customer then would have to pick the desired size and color in one option, like: S,

Update all WooCommerce product prices to 2 decimals in database

我是研究僧i 提交于 2019-12-06 16:34:14
Many of my products have prices like £3.4560 etc. I need them to rounded and stripped to just 2 in the database. The output of 2 decimal places in WooCommerce is not enough and fails to work with a Tax Toggle plugin. Is there a database query that can do this? I've seen some bits on Rounding and Truncate but not sure how to execute this as my knowledge is poor. Any help is appreciated. Update 2: (Added some code to clear all related product transient cache) Here is some code that will update all the product prices (make a database backup before): global $wpdb; $postmeta = $wpdb->prefix .

Close WooCommerce Product Tabs by default

烂漫一生 提交于 2019-12-06 16:09:47
By default Product Tabs in WooCommerce auto opens the first one. Is it possible to have them all closed by default, requiring you to click it to see more? I have tried the following code, but it does not seem to do it. Perhaps there is a PHP code that does it or something simple? I already tried this without luck : setTimeout(function() { var $tabs = jQuery( '.wc-tabs, ul.tabs' ).first(); $tabs.parent().find('#tab-description').hide(); $tabs.parent().find( '.tab-title-description' ).removeClass('active'); }, 10); Updated - You should try instead: // Conditional Show hide checkout fields based

Add custom field in products to display in cart, checkout and in orders

心不动则不痛 提交于 2019-12-06 16:03:52
I am using a Custom post type and integrated woocommerce on it, I am able to add an add-to-cart button on the pages and can add it to cart, so it works fine here is my code class WCCPT_Product_Data_Store_CPT extends WC_Product_Data_Store_CPT { /** * Method to read a product from the database. * @param WC_Product */ public function read( &$product ) { $product->set_defaults(); if ( ! $product->get_id() || ! ( $post_object = get_post( $product->get_id() ) ) || ! in_array( $post_object->post_type, array( 'products', 'product' ) ) ) { // change birds with your post type throw new Exception( __(

Rename Length to Diameter in WooCommerce formatted product dimensions output

那年仲夏 提交于 2019-12-06 16:02:56
I’m using this woocommerce_format_dimensions filter hook to replace displayed dimensions format from 1 x 1 x 1 in to 1 L in. x 1 W in. x 1 H in. add_filter( 'woocommerce_format_dimensions', 'custom_formated_product_dimentions', 10, 2 ); function custom_formated_product_dimentions( $dimension_string, $dimensions ){ if ( empty( $dimension_string ) ) return __( 'N/A', 'woocommerce' ); $dimensions = array_filter( array_map( 'wc_format_localized_decimal', $dimensions ) ); foreach( $dimensions as $key => $dimention ) $label_with_dimensions[$key] = $dimention . ' ' . strtoupper( substr($key, 0, 1) )

Replace product image by a placeholder based on user roles in WooCommerce

霸气de小男生 提交于 2019-12-06 16:00:18
In WooCommerce I am using user roles to define what each user role can see. If the user is "customer" or "administrator", he is able to see the product image, otherwise he see WooCommerce default placeholder image. For that I use the code below: function woocommerce_product_get_image_id_callback( $value ) { global $current_user; if ( in_array( 'customer', (array) $current_user->roles )|| in_array( 'administrator', (array) $current_user->roles )) { return $value; } else { return false; } } add_filter( 'woocommerce_product_get_image_id', 'woocommerce_product_get_image_id_callback', 10, 1 ); It