Tag Info

New answers tagged

1

May be you have just enabled the 'Enable shipping' from shipping options page(Woocommerce -> Settings -> Shipping ). You need to enable the Shipping Methods also. For enabling shipping methods click on shipping method name from shipping methods table displayed on shipping options page. Check the checkbox ' Enable this shipping method ' and save the ...


0

Here is the code to get the download link for a downloadable product in WooCommerce. $downloads = $product->get_files(); foreach( $downloads as $key => $each_download ) { echo '<a href="'.$each_download["file"].'">Download</a>'; }


0

With the help of a more knowledgeable colleague, we got it working. Here's the code: /** Add custom column headers **/ function wc_csv_export_modify_column_headers( $column_headers ) { $new_headers = array( 'fund' => 'fund', 'appeal' => 'appeal_code', ); return array_merge( $column_headers, $new_headers ); } add_filter( ...


0

I was directed to this post – which solved my problem 100%. Here is the solution I used from that post. // get all product cats for the current post $categories = get_the_terms( get_the_ID(), 'product_cat' ); // wrapper to hide any errors from top level categories or products without category if ( $categories && ! is_wp_error( $category ) ) : ...


0

It might not be ideal to disable the onboarding wizard but I think I may have found an answer for anyone seeking to disable the wizard: function wc_disable_onboarding_wizard() { return false; } add_filter( 'woocommerce_enable_setup_wizard', 'wc_disable_onboarding_wizard' );


1

This is what I have used to create a custom order status called "Invoiced". Add this to your theme's functions.php // New order status AFTER woo 2.2 add_action( 'init', 'register_my_new_order_statuses' ); function register_my_new_order_statuses() { register_post_status( 'wc-invoiced', array( 'label' => _x( 'Invoiced', ...


0

For this purpose there is get_term_link function (documentation). <a href="<?php echo get_term_link( 42 ,'product_cat') ?>">Fine Art ... etc.</a> Product category is just WP taxonomy, so there is plenty of functions to work with. In this case you have to know your product category ID (taxonomy term ID, actually). When editing category, ...


0

You should use "tax query" like this: $args = array( 'post_type' => 'product', 'posts_per_page' => 5, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'terms' => 5, ), ), ); Using taxonomy name (product_cat) as WP_Query parameter is deprecated.


1

Product category is just a regular wordpress taxonomy. You can get the link like this: echo esc_url( get_term_link( 6, 'product_cat' ) ); You can use slugs too: echo esc_url( get_term_link( 'category-slug', 'product_cat' ) );


0

I have been working with a plugin called TM Extra Product Options and I am fairly sure you could achieve your goals using that. It isn't the prettiest plugin from a UI perspective, but it has a lot of functionality and good support if you use their forums. You could use a select box for number of characters and then set a conditional field to appear when ...


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


0

my pleasure to help you. I will give suggestions until we find the right solution. I suggest that you: - add a custom product attribute to use for variations - set a name of your choice and values likes this [ One-Five |Six| Seven | Eight|Nine| Ten ] so you can set prices to them - add an input text field on the front end with a fixed number of caracters ...


0

Ok I got it working. Not sure what I had wrong first time around but I just copied the first function and replaced order with user. Also included the code to display the field in user profile for reference. function save_passport_to_user_meta( $user_id, $posted ){ // don't forget appropriate sanitization if you are using a different field type ...


0

Have you gone back into your variation products to insure they are still intact? There has been quite a few changes to the way WooCommerce handles variation products although everything should be fine. What version were you upgrading from? Have you set your default variations on your products? If not, edit your product, navigate to "Variations" and ...


0

$word_product = $_GET['username']; $word_price = ""; $word_lenght = count( $word_product ); if ( $word_lenght <11 ) { if ( $word_lenght>= 0 && $word_lenght <=5 ){ $word_price = x ; }else { if( $word_lenght >5 ){ $word_price = x + ( $word_lenght-5 ) * y ; } } } Try out this algorithm


0

woocommerce_register_post does fire. But only if both email and password are filled in. So placing your extra form fields in before the form using woocommerce_register_form_start doesn't actually move those to the start for the validation. Kind of annoying, it took me too long to figure out, but there you go.


1

WordPress default importer will not work for WooCommerce product attributes. There is a plugin available to import WooCommerce products which handles import for products as well as their attributes. I'll not paste the plugin URL here since it's a third party plugin, but if you google for 'WooCommerce import', you will easily get that plugin.


0

You need to place the following before your two types to join them: 'meta_query' => array( 'relation' => 'AND' so you'll have: $args = array( 'meta_query' => array( 'relation' => 'AND' array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => 10, 'meta_key' => '_featured', ...


0

You can simply update the usermeta just after or before update_post_meta in your code as follows if(is_user_logged_in()){ $user_id = get_current_user_id(); //will work only if the user is logged in (to make sure user login, you can disable guest checkout from WooCommerce settings) update_user_meta( $user_id, '_passport_field', ...


0

After so much research I figured it that the issue is due to a custom function I was trying to hook to the product page. All this while the custom function was wrongly hooked and I corrected it now.


0

Hereby my answer to my own post. I hope this is helpful to others too! To create the category, I used an array with the data per category needed for the function wp_insert_term. Then i looped trough that array,and used a fetch_media function that uploads the image found in the image-path given to that function, and returns an attachment ID. I then call ...


0

Yes, you can import woocommerce products to wordpress database.There are several woocommerce addon's available in market. You can use the plugin like Woocommerce CSV importer


0

It's actually pretty simple to change the title in content-product.php, but you won't be able to do it with a hook. Near the top of the file, you should see this line: Override this template by copying it to yourtheme/woocommerce/content-product.php All you have to do is copy the file to the above directory, replacing "yourtheme" with your theme's actual ...


-1

in WordPress, you cannot just "overwrite" a hook (that's works only for pluggable functions) but, you can add new fonction to the same hook and remove an action. try something like this : add_action("init", function () { // removing the woocommerce hook remove_action('woocommerce_shop_loop_item_title', 'change_product_title'); }); // add a new ...


1

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.


0

This will get you started on the right track. Call wp_get_current_user() whose return value will be either one of a WP_User object or null value. Assuming we have a WP_User object, we can inspect the roles property found on the object and conditionally check if it matches an allowed role prior to redirecting the user. function redirect_user() { $user ...


0

You have to update post meta _price and _regular_price. As woocommerce stores each variation of product as a single product. So instead of passing variable products id you need to pass variation id to update_post_meta.


0

This is a theme related issue. You will have to check with the theme developer regarding missing Header tags. Yoast SEO plugin is not something one uses to add header tags.


1

Orders are just regular posts: wp_delete_post($order_id,true);


0

Thanks WisdmLabs. I traced it finally after the discussion. The changes in product page are appearing now. Below is the mistake I have done.I am posting this as it might help others with similar problems. In my plugin I am calling file B in file A using require_once. I have placed my function timeslot_display() and hook calling line in file B which did not ...


-1

What about this ? $query_withMeta_search = new WP_Query( array( "post_type" => "product", "s" => $search_query, "meta_query" => array( "key" => "_sku", "value" => $search_query, "compare" => "LIKE" ) ) );


-1

Please check your theme details. In your theme show detail about column write this column class in your div. for ex:->Avada theme give class col-md-3. Product 1 Product 2 Product 3 Product 4 It display 4 product in a row.


2

There is almost never a scenario where executing PHP code entered from the wysiwyg editor is a good idea. It opens up a whole bunch of security issues. The best way to achieve what you are looking for is to setup a custom short code that will return the link you are interested in. Add something like this to your functions.php file in your theme. ...


1

It seems that the OP have managed to solve his/her problem by doing this, which can be found at Different menus for logged-in users. if ( is_user_logged_in() ) { wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) ); } else { wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) ); } The more shorter way to achieve that is by ...


1

You can use the WordPress function is_user_logged_in() to check that, and create some basic if statements to show and hide the appropriate code.


1

You could try adding some css to your theme's style.css file: .onsale { display: none !important; } If you're using a pre-built theme, it's wise to do this in a child theme's style.css, as the change won't be overwritten if you update your theme. Further reading: https://codex.wordpress.org/Child_Themes


0

Not sure why your object is returning the non-object notice, but you can set the output of get_term_by to OBJECT, ARRAY_A, or ARRAY_N - You'll want to use ARRAY_A and then access the term ID via $term['term_id'].


0

Here is some generic js you could use to accomplish this. This code is intentionally generic, so you will need to make it work for your scenario. You can load up your various states and hide them with the 'js-display-toggle' class. When the appropriate country is chosen from 'base' select menu, then you remove the toggle class and show those state. ...


-1

Just the csv file where is "external" to "simple" it's the easy way.


1

get_terms() accept an array of arguments as second parameter. One of those parameters are include include (integer) An array of term ids to include. Empty returns all. You already have your selected term ids in an array, so just simply pass them to the include parameter in the array of arguments in get_terms() $terms = get_terms( $taxonomy, ...


0

in comments I propose to make the order as public but I found a easier way to display a order : with a shortcode i try this in a plugin : add_shortcode("view_order", function ($atts, $content = "", $tag) { if (!isset($_GET["order_id"])) { return "no id"; } $order = get_post($_GET["order_id"]); if ( !isset($order) || ...



Top 50 recent answers are included