Get woocommerce product price by id [closed]

You can create a product object using the following function: $product = wc_get_product( $post_id ); And after that you will be able to access to all product’s data. All available methods can be found here, but the ones you need are: $product->get_regular_price(); $product->get_sale_price(); $product->get_price();

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

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]

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)