Tag Info

Hot answers tagged

4

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


3

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


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

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

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

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


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

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

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

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

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

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


2

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

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


1

A simple str_replace would do the trick: $links = paginate_links( $arguments ); $links = str_replace( 'href="', 'rel="nofollow" href="', $links ); echo $links;


1

You are most probably exceeding the maximum execution time when trying to retrieve 7000 posts/products, or specifically more than 2000 posts/products. To be quite honest with you, 7000 posts/products (or even just a list of posts/products) all packed in one single page is not only going to drive you crazy, but anyone visiting your site. I can imagine how ...


1

The opposite of is_page() will be ! is_page(). In php the ! is used as negative, so ! is_page( 42 ) will means something like if we are not on page ID 42, do something, in other words exclude page ID 42


1

Thanks Pieter, that solved the issue. I'm writing below some details just in case someone comes here in future. As stated by Pieter in answer above, using !is_page is for excluding the page in opposite of using is_page for including functions for that page. In my case, I noticed two things. <?php if(!is_shop() && (!is_front_page())) {?> I ...


1

Nope, the WP is pretty flexible about this and will perfectly handling omitted fields. Including assigning IDs (which is actually best left to it, outside of edge cases when exact IDs must be imported). The only situation that natively won't let you create post is if neither of title/content/excerpt is provided and post type supports any of them. Even then ...


1

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


1

The solution for this is, in my opinion, divided into two steps. The first step is to set the variable, which defines the affiliate, that sends you the visitor. The second step is to display an appropriate logo based on the value of the first variable. The solution for the first step would probably look somewhat like this: if( isset($_GET['affiliate']) ...


1

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


1

WooCommerce uses a custom post type called product for its product. Your shop page appears to be looking for a products archive. I can tell this because of the slug - post-type-archive-product Have you tried renaming your custom shop template file archive-product.php? This should override the default archive template.


1

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.


1

A cleaner way to display a delimiter would be a CSS-border (like Aibrean suggested). But you can set up the filter to fit your needs: add_filter( 'woocommerce_breadcrumb_defaults', 'custom_woocommerce_breadcrumbs' ); function custom_woocommerce_breadcrumbs() { return array( 'delimiter' => '<li class="separator"> | </li>', ...


1

WooCommerce adds classes to indicate when a product has a thumbnail specified, so you can address this with CSS. .product .images { display: none; } /* hide images div by default */ .product.has-post-thumbnail .images { display: block; } /* show images div when thumbnail is present */


1

Add the following to your theme's function.php. Default values are shown below, except changing 'number' from 45 to 15. Only the changed values need to be included, so you can either leave the default values or remove/comment out those lines. For Wordpress Tag Cloud widget: function custom_tag_cloud_widget() { $args = array( 'smallest' => ...



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