Tag Info

Hot answers tagged

5

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 ) { ...


5

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 ...


4

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 ...


4

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 } ?>


3

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 */ }


3

WooCommerce questions are off-topic, but since reviews are merely comments, I think we can make the case that ordering comments is still on-topic. wp_list_comments() has a reverse_top_level parameter that will set the most recent comment first and then go backwards. Assuming it works like I think it should then you'd want to add this parameter to ...


3

Capabilties - for guests? Your problem is that a guest doesn't have any capabilities. And when posts get processed, they need to pass certain checks. One is unfiltered_html. From Codex: Allows user to post HTML markup or even JavaScript code in pages, posts, comments and widgets. Note: Enabling this option for untrusted users may result in their ...


3

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


3

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 ...


3

I think I fixed the issue with the following extended function in my plugin: function localize_backend( $locale ) { // set langauge if user is in admin area if( defined( 'WP_ADMIN' ) || ( isset( $_REQUEST['pwd'] ) && isset( $_REQUEST['kau-boys_backend_localization_language'] ) ) ){ // ajax call from frontend if ( ...


2

I got it working for my situation by using update_post_meta and wp_insert_post. Because I already setup my attributes and terms all I needed was a way to add to the above code so that when the product is created it not only will assign the attributes to the product but insert them as variations in the database. Here is my solution: //insert variations ...


2

I have been working on this myself with very little coding experience. So far I have found that you can add in another value but you need to update a few of the files in the woocommerce template. In the single-product-reviews.php, just repeat the code from the <p> to </p>. See where I have added in the newrating star select if ( ...


2

20 is the priority. To remove, must use the same priority as the one that was set in the add_action.


2

You don't need a plugin, if your images names really match with product SKUs and you use media uploader to upload the file, you can use a single function hooked in add_attachment and you are done. Once it require some work, I'd avoid to upload all the hundreds of images in one "session", probably you can upload sets of 25/50 images per time with no ...


2

You're _doing_it_wrong, as $product is an object. I'm pretty sure you want something like this: $args = array( 'post_type' => 'product', 'posts_per_page' => 4, ); $featured_query = new WP_Query($args); if ($featured_query->have_posts()) { while ($featured_query->have_posts()) { $featured_query->the_post(); ?> ...


2

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 ...


2

Found solution for this problem. It turned out that woocommerce affects post_type query variable in pre_get_posts filter without checking that another post_type has been requested. It's done in WC_Query.product_query method: if ( ! $q->is_tax( 'product_cat' ) && ! $q->is_tax( 'product_tag' ) ) $q->set( 'post_type', 'product' ); Fix ...


2

I don't know Drupal, however, seems to me that what is "node" in drupal is "post type" in WordPress. By default WordPress has several post types: posts, pages, atthachments, menu items, revisions (these post types are often referred as "built-in"). You can register any number of custom post types, aka CPT. Post types, in database, differe one from another ...


2

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 = ...


2

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 ...


2

There is no actions/filters to hook to. You need to override standard WC_Email_Customer_New_Account class and implement your own logic. To do it you need to create your own class which will inherit that class and register it. class WPSE8170_Email_Customer_New_Account extends WC_Email_Customer_New_Account { function trigger( $user_id, $user_pass = '', ...


2

You can add this snippet below to your themes functions file to create the message you want displayed. (For all Woocommerce conditional options, visit their codex here: http://docs.woothemes.com/document/conditional-tags/) add_filter ('the_content', 'royal_woocommerce_maintenance'); function royal_woocommerce_maintenance($content) { if( is_woocommerce() ...


2

Woocommerce does hijack the main query on the shop page / product queries, so it's possible that you're used to referencing your custom fields within the loop or in some other context where the global $post is the page you are on, but in this case the contents of $post will be Woocommerce products and not the page. If this is for your base shop page you ...


2

You should be able to do this with the same filter that is talked about here. The full-size images are being kept by WordPress. It's not really a WooCommerce thing. As well as the settings for images in WooCommerce you will also need to set minimum image size in WordPress's Settings>Media... Then this script (see the link above for complete discussion) ...


2

i think this is what you need: $args = array( 'orderby' => 'name', 'hide_empty' => 1 ); $category_terms = get_terms( 'product_cat', $args ); foreach($category_terms as $cat_term){ echo $cat_term->name; } btw: woocommerce is offtopic here!


2

wp_enqueue_style supports dependencies. So, if you make the WooCommerce style a dependency for your new stylesheet then your stylesheet will always load after the WooCommerce stylesheet. Something like this ought to work, but it is untested: function enqueue_style_after_wc(){ $deps = class_exists( 'WooCommerce' ) ? array( 'woocommerce-layout', ...


1

This is not Woocommerce specific, just the regular WordPress term edit screen. So you can use the normal action {$taxonomyname}_edit_form_fields. Example: add_action( "product_cat_edit_form_fields", function() { ?> <tr class="form-field"> <th scope="row">Additional image</th> <td>Some image upload code ...


1

Can't you change CSS rules? .hide-item-not-login{ display: block !important; } .logged-in .hide-item-not-login{ display: none !important; } EDIT To add login/logout menu item, you will need to add one more class to logout menu item. Let's say you added class .logout-link to logout menu item. Then you can add css like this. .hide-item-not-login{ ...


1

This can be done by having the display: none; only on the .logged-in selector. Like this... .logged-in .hide-item-not-login { display: none; } You might want to change that .hide-item-not-login to a more accurate .hide-item-login or something to make it more clear for this changed use case. Though it makes no difference to the functionality of it.


1

This happened to me. I installed a thumbnail regenerater plugin, this seemed to do the job for me.



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