Hide prices and checkout functionality in woocommerce

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 ); remove_action( ‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 ); you can dig into content-product.php and content-single-product.php if you need to remove more stuff. I can imagine there’s more than just the prices/buttons you want to … Read more

get woocommerce My account page link

You can get the WooCommerce my-account URL as below <a href=”https://wordpress.stackexchange.com/questions/213612/<?php echo get_permalink( get_option(“woocommerce_myaccount_page_id’) ); ?>” title=”<?php _e(‘My Account’,”); ?>”><?php _e(‘My Account’,”); ?></a> Now you can insert this in completed order mail template too. <h2> <a href=”https://wordpress.stackexchange.com/questions/213612/<?php echo get_permalink( get_option(“woocommerce_myaccount_page_id’) ); ?>” title=”<?php _e(‘My Account’,”); ?>”>Go to your account page for review</a> </h2> <a href=”http://animax.cf/product/happy-ninja/#reviews”> … Read more

List of JS events in the WooCommerce frontend

On a hunt for the same I took a little dive into the JS source files. Woocommerce Javascript events Woocommerce Checkout JS events $( document.body ).trigger( ‘init_checkout’ ); $( document.body ).trigger( ‘payment_method_selected’ ); $( document.body ).trigger( ‘update_checkout’ ); $( document.body ).trigger( ‘updated_checkout’ ); $( document.body ).trigger( ‘checkout_error’ ); $( document.body ).trigger( ‘applied_coupon_in_checkout’ ); $( document.body … Read more

Display featured products through custom loop in woocommerce on template page

Change your args to be like this: $meta_query = WC()->query->get_meta_query(); $meta_query[] = array( ‘key’ => ‘_featured’, ‘value’ => ‘yes’ ); $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘showposts’ => 6, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘meta_query’ => $meta_query ); If you go to wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php (@595) you can find how it’s done for … Read more

Get the product list of a given Category ID

I suspect the main problem is that you should be using the WP_Query object rather than get_posts(). The later by default only returns items with a post_type of post not products, So given a category with ID 26, the following code would return it’s products (WooCommerce 3+): $args = array( ‘post_type’ => ‘product’, ‘post_status’ => … Read more

Woocommerce – Add a product to cart programmatically via JS or PHP [closed]

OK so here’s how I solved it in the end. A quick and dirty example, uses JQuery. <a id=”buy” href=”#”>Buy this!</a> <script> $(‘#buy’).click(function(e) { e.preventDefault(); addToCart(19); return false; }); function addToCart(p_id) { $.get(‘/wp/?post_type=product&add-to-cart=” + p_id, function() { // call back }); } </script> This just makes an AJAX GET request to the cart url /wp/?post_type=product&add-to-cart=[PRODUCT_ID]

How to add product in woocommerce with php code [closed]

The method below is now out of date as WooCommerce have added the wc_product_meta_lookup table which also needs to be updated with some of the meta values. Woo have now provided a CRUD interface so use that instead. $post_id = wp_insert_post( array( ‘post_title’ => $title, ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘post_content’ => $body, )); … Read more