Hot answers tagged

17

What ended up working for me was adding "&install_woocommerce_pages=true" to the Settings page URL.


17

luckily woocommerce has many hooks, this removes prices and buttons: remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );...


17

Its pretty easy one you have worked out the data added in the post meta. Trouble I am having is adding downloadable products to the store. below is the code i am using it lists all the post meta that is used by woo commerce. This publishes a product however the download link will not attach. Originally when i started i made an error with the array that ...


16

You need to create a new loop for that. Here's the code I use for displaying products from a specific category on the home page: <ul class="products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'shoes', 'orderby' => 'rand' ); $loop = new WP_Query( $args ); while ( $...


12

From the __get() method in the WC_Order class you can see that the user_id property is taken from/stored as _customer_user post meta for the order in question. /** * __get function. * * @access public * @param mixed $key * @return mixed */ public function __get( $key ) { // Get values or default if not set if ( 'completed_date' == $key ) { ...


9

Extending the above code (thanks Ewout), the following code will get rid of all prices and 'add to cart' buttons on all woocommerce products, as well as provide an explanation as to why. I needed the code for a website that offers direct selling products and to comply with their rules, I cannot show prices to the general public. Add the filter to your ...


9

Figured it out! The code below automatically lists all categories and each categories posts! $args = array( 'number' => $number, 'orderby' => 'title', 'order' => 'ASC', 'hide_empty' => $hide_empty, 'include' => $ids ); $product_categories = get_terms( 'product_cat', $args ); $count = count($...


7

Figured this one out. I was missing a couple parameters needed to add a variable product to my cart. The missing params are the variation_id and the attribute type that the variation_id is referring to. The variation id can be found in the admin > woocomerce > products and under the variations tab next to the product variation you have created. The ...


7

There is an easier way to get the page-creation dialog to appear. Simply go to WooCommerce > Pages and unset all of the select boxes for pages (including the shop base option). Then if you de-activate and re-activate it will ask you whether or not you want to install the pages.


7

I had to do something similar a while ago, this is what was working for me: In the example, the custom input name is "test_field" inside the add to cart form, and this way when you dump the cart_contents, you can see the value somewhere at the end //Store the custom field add_filter( 'woocommerce_add_cart_item_data', 'add_cart_item_custom_data_vase', 10, 2 ...


7

Another update (Sept. 2015): I can use get_term_link after all. The problem was that the string needed to be converted to an integer. Used a Stack Overflow tip for the fastest way to convert it using the (int)$value in PHP. So it would look like this if you don't want to use the slug in the foreach loop: $woo_cat_id_int = (int)$woo_cat_id; //convert ...


7

An attachment is a Post The posts table contains information on the attachment post. In WordPress every uploaded media has it's own post entry, where post_type is 'attachment' and post_status is 'inherit'. In fact, you can get attachment post types using functions used to get other post types, like post, page or any CPT. That includes WP_Query, get_posts(...


6

i currently work on a woocommerce v2.1.12 shop and it seems they chaged that behavior. my ajax url to add items to the cart has to look like this: ?add-to-cart=[PRODUCT-ID]&variation_id=[VARIATION-ID]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG]&attribute_[ATTRIBUTE-NAME]=[ATTRIBUTE-SLUG] example: http://example.com/store/category/product/?...


6

Just had the same problem. First uninstall the plugin. Then you have to delete all rows containing "woocommerce" in the table "wp_options" on your database. Especially "skip_install_woocommerce_pages". Now install the plugin again. The notification for automatically creating pages will pop up.


6

I had this same problem. You must clear cache (or just delete cookies) before you will see your override. Not sure why :)


6

You have differents languages in your site, although your frontend is not multilingual, you serve one language in frontend and another in backend. Ajax in Wordpress is processed in the "admin area" (wp-admin/admin-ajax.php), so the reponse of an ajax request will be in the language defined in the admin area. "English" in your case. I don't know exactly how ...


6

I solve This To get the current category ID. $cate = get_queried_object(); $cateID = $cate->term_id; echo $cateID; and it works like a charm.


5

Put this in your functions.php file: function wpse_131562_redirect() { if ( ! is_user_logged_in() && (is_woocommerce() || is_cart() || is_checkout()) ) { // feel free to customize the following line to suit your needs wp_redirect(home_url()); exit; } } add_action('template_redirect', '...


5

You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce. <?php if ( class_exists( 'WooCommerce' ) ) { // code that requires WooCommerce } else { // you don't appear to have WooCommerce activated } ?>


5

Looking further into the WooCommerce source, they fortunately, provide a filter named woocommerce_product_data_tabs which will allow you to conditional unset tabs. I've provided an example below: add_filter('woocommerce_product_data_tabs', function($tabs) { /** * The available tab array keys are: * * general * inventory * ...


5

You should use 'orderby' => 'meta_value_num' and 'meta_key' => 'rating' as specified by the WordPress Codec. Using meta_value_num with the assumption your ratings are numeric values Reference: Orderby Parameters


4

I couldn't find this documented anywhere, but the solution is pretty simple. In single_product_review.php, the arguments passed to wp_list_comments are filtered: wp_list_comments( apply_filters( 'woocommerce_product_review_list_args', array( 'callback' => 'woocommerce_comments' ) ) ); by adding reverse_top_level to the arguments, the order is ...


4

I suspect the main problem is that you should be using the WP_Query object rather than get_posts(). The later by default only returns items with a post_type of post not products, So given a category with ID 26, the following code would return it's products: $args = array( 'post_type' => 'product', 'post_status' => '...


4

Your $scr in your wp_register_script() function is wrong. Given that your functions.php is inside your plugin, and your removeArrows.js is in the root of your plugin, your $scr should look like this plugins_url( '/removeArrows.js' , __FILE__ ) Another point of note, it is always good practice to load your scripts and styles last. This will ensure that it ...


4

You should check WooCommerce -> Settings -> Emails (tab) and On the "New Order" sub-link you'll need to add your clients email there, otherwise Woo will use the default admin email address.


4

Use get_current_blog_id() to check the current site. To run on site 2 only, use this: function new_meta_values($order_id) { if ( 2 !== get_current_blog_id() ) return; /* the rest of the function code */ }


4

Have tried your code and it works fine and infact it also gives out the details of each product in the orders. The code which i tried $filters = array( 'post_status' => 'any', 'post_type' => 'shop_order', 'posts_per_page' => 200, 'paged' => 1, 'orderby' => 'modified', 'order' => 'ASC' ); $loop = new WP_Query($...


4

Okay, based on answers on link above (where I got the old code and there are people that help to answered), I put the modification code for my website. I tried it and it's working like charm. Change: add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 ); Into : add_action( 'woocommerce_variation_options', '...


4

I know this post is old, but to keep this question updated: As of WooCommerce 2.4.4 woocommerce_process_product_meta_variable no longer works, and it must be changed to woocommerce_save_product_variation So, Change: add_action( 'woocommerce_process_product_meta_variable', 'save_variable_fields', 10, 1 ); Into: add_action( '...


4

I finally tried using var_dump() on $item and $_product, which are both used in the email-order-items.php template. $_product revealed a post object, which itself has a post_excerpt property, which looks like it holds the contents of the "Product Short Description" from the WooCommerce product form. So, to add the description beneath the item name, I added ...



Only top voted, non community-wiki answers of a minimum length are eligible