Tag Info

Hot answers tagged

6

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


5

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


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


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

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


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

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

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


1

I'll try and answer this for you based on the limited information you've provided... When using woocommerce, you also need to define the various image sizes for your products in the dashboard at Woocommerce > Settings > Product Image Sizes Whatever size you choose should match the sizes in your Media Library settings, but you've already said that these are ...


1

Based on your comment to your question, you might take a look at http://www.wpallimport.com they have a woocommerce addon that works pretty well and includes the product image importer. With a custom CSV i'm sure you could wrangle it to import all in one import for you (including the media manager bit). Now if you are looking to attach existing uploaded ...


1

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


1

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


1

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


1

You could treat products like any other post type and query using get_posts(). Limit the number of posts retrieved to 1 and change the orderby parameter to random: $args = array( 'posts_per_page' => 1, 'orderby' => 'rand', 'post_type' => 'product' ); $random_products = get_posts( $args ); foreach ( $random_products ...


1

This is mostly pure PHP, but you need to implode the array. add_shortcode('bundled_ids','bundled_ids_func'); function bundled_ids_func() { $meta_values = get_post_meta( get_the_ID() , '_bundled_ids', true ); if (!empty($meta_values)) { $mydata = implode(',',$meta_values); // add this line return $mydata; } }


1

Found this neat little article on it, try this out! http://ryansechrest.com/2013/04/remove-post-type-slug-in-custom-post-type-url-and-move-subpages-to-website-root-in-wordpress/ It's a guide/tutorial, so you should be able to get more information on what's going on here if you visit his site. By the way, it's against the rules to ask for a plugin here. ...


1

In the Edit Product screen, under the Custom Fields heading, create a new field, for example product_author. Then you need to edit your template file where you want to display the field, probably content-product.php, and call it this way: <?php echo get_post_meta($post->ID, 'product_author', TRUE); ?>


1

This code should do it for you. It add an action to the updating of the WordPress profile, checks if the email has been updated, and if so, it updates the Woocommerce address as well. add_action('profile_update', 'sync_woocommerce_email', 10, 2) ; function sync_woocommerce_email( $user_id, $old_user_data ) { $current_user = wp_get_current_user(); ...


1

First, store the custom field when you're editing your product. Lets say you're using the custom_shipping_cost custom field. Make sure its stored as a number, 20 for example, NOT $20.00 Then, you need to display this field on the cart page. Sadly, theres no filter for adding a new column in the cart table, so you need to edit the template file, or if its ...


1

Your problem is not Woocommerce specific, and can be generalised as: Given a term in a taxonomy, how do I attach a chunk of text to that term and display it in the term listings? In this case, the taxonomy is the one provided by Woocommerce. To do this you need to first get the current term being queried: global $wp_query; $term = ...


1

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


1

There is nothing out of the box that will let you send an email to multiple email address for one account, but you can hook a function to wp_mail filter and check based on to address or subject line and add your cc/bbc to that filter, ex: // Add extra contact info fields to user profile page function extra_contact_info_wpa_134454($contactmethods) { ...


1

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


1

The shopping cart is a main structure of the WooCommerce checkout process and cannot be completely disabled. As there is no exact solution, the best way to do what you want, in my opinion, is go to WooCommerce Settings -> Checkout and remove the selected page for the cart. This way, there will be no front-end for the cart whatsoever, although selected ...


1

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

I am not a jQuery expert, but I ran into the same problem and I believe I have a workable solution. The problem is that each time you run wp_localize_script it creates a javascript variable using the $name setting. In your case that is 'carouselvars'. As this is set before the jQuery in run, only the last values passed to the variable are 'seen' by jQuery, ...


1

If you're post type is called 'product' then if you remove the code that registers your post type, and activate, say WooCommerce, the plugin should recognize the posts. You would need to configure some of the meta fields, however. Following up on your comment, WooCommerce registers the product post type with the following pertinent code: if ( ...


1

I had the same issue in a client site which turned out to be a php POST variable limit (1000) which is an attempt for PHP to solve some security issues. This can be easily changed via the php.ini config file ex: max_input_vars = 5000 you should also note the max_input_nesting_level But we ended up using a grouped products instead of variations.


1

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



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