Forcing WooCommerce customers to create account before checking out
Forcing WooCommerce customers to create account before checking out
Forcing WooCommerce customers to create account before checking out
Thanks to @Tom J Nowell’s help, I fixed my code to persist the created page ID to Options: function install_xxx() { $post = array( ‘post_title’ => __( ‘Thank You’, ‘xxx’ ), ‘post_content’ => __( ‘Lorem ipsum dolor.’, ‘xxx’ ), ‘post_status’ => ‘publish’, ‘post_name’ => ‘thank-you’, ‘post_type’ => ‘page’ ); $post_id = wp_insert_post( $post, true ); … Read more
There’s one more argument that you’re not passing, and that includes the WC_Email object ($object is actually an indicator of the object the email is “for” – customer, product, or email). That last argument passed should allow you to access the methods in WC_Email to figure out the recipient, and therefore the user (which should … Read more
Answer: the code above works perfectly fine; it just doesn’t echo anything inside the admin section. The ‘stuff’ I did with the update_option hook didn’t work for reasons independent of the code above.
I have replaced woocommerce_template_single_add_to_cart(); by this global $product; if( is_a( $product, ‘WC_Product_Variable’ ) ){ woocommerce_variable_add_to_cart(); } else { woocommerce_simple_add_to_cart(); } and it worked as i wanted.
How can Use custom input field in functions.php page?
Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
wp_insert_post_data is applied before the post data are inserted to the database. use the save_post hook instead to set the custom taxonomy terms. That was it. Thanks Sally for the recommendation.
Yes, you can use the pre_get_posts hook. From the docs: Fires after the query variable object is created, but before the actual query is run. In other words, this hook allows you to alter the WP query before it runs, so you can throw in whatever conditionals to suit your needs. Here is the structure … Read more
Thank you very much @Tom J Nowell and @Sally CJ . As you pointed out, it worked with the below: function remove_inline_style(){ if ( is_page( ‘live’ ) ){ remove_action( ‘wp_enqueue_scripts’, array( Design_Scheme::get_instance(), ‘header_style_css’ ), 11 ); } } add_action( ‘wp_enqueue_scripts’, ‘remove_inline_style’); thank you for your help.