Is there any way to find which action/hook is fired?
Try this plugin which will show you which actions get fired on a given page.
Try this plugin which will show you which actions get fired on a given page.
$args = array( ‘post_type’ => ‘product’, ‘meta_key’ => ‘YOUR_FIELD_ID’, ‘meta_value’ => array(‘yes’), //’meta_value’ => array(‘yes’), ‘meta_compare’ => ‘IN’ //’meta_compare’ => ‘NOT IN’ ); $products = wc_get_products($args); foreach ($products as $product) { //do your logic }
Try this code to change the default billing country on the checkout page. add_filter( ‘default_checkout_billing_country’, ‘change_default_checkout_country’ ); function change_default_checkout_country() { return ‘US’; // country code } To change default shipping country on the checkout page function change_set_checkout_field_input_value_default($fields) { $fields[‘shipping’][‘shipping_country’][‘default’] = ‘Australia’; return $fields; } add_filter( ‘woocommerce_checkout_fields’, ‘change_set_checkout_field_input_value_default’ );
product-category URL uses taxonomy-product-cat.php which calls archive-product.php you will need to override it by creating the same file with the same name in themefolder/woocommerce/archive-product.php You can open any file in templates folder in the WooCommerce plugin and you will find a line in the very top comment describes how to override the file. Don’t forget … Read more
Alright, so since WC Subscriptions is creating it’s own array for columns. Any filter priority lesser than their function will simply make your code non-functional. So what I did is I changed priority from 10 to 1000 so that my codes fire after their code. add_filter( ‘manage_shop_subscription_posts_columns’, function ($columns) { $columns[‘my_field’] = __(‘My Field’); return … Read more
It’s actually quite simple. Use the woocommerce_product_post_type_link_parent_category_only filter: add_filter( ‘woocommerce_product_post_type_link_parent_category_only’, ‘__return_true’ ); Tried and tested working. PS: The code would go into the theme functions file and __return_true() is a WordPress function.
The action hook publish_post doesn’t work for custom post types. You need to use the following format: publish_{$custom_post_type} As you are using Woocommerce this post type is product so you want to use: publish_product.
Woocommerce is a plugin for wordpress and cannot run multiple stores. However you may want to run wordpress as a multisite installation and for each site, you install plugin and can control all three stores from one wordpress admin. However i will recommend Magento, as its capable of multi store. Hope it helps
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’, ‘woocommerce-smallscreen’, ‘woocommerce-general’ ) : array(); wp_enqueue_style( ‘my-style’, ‘my-style.css’, $deps, … Read more
While this question is probably technically off topic since it relates to woo, there’s definitely some stuff that could be answered that will help other users in the future, plus, I really have been there with the multi-day frustration stuff and would have killed for a life line. There’s a few things at play here, … Read more