Skip to main content

Posts

Showing posts from November, 2018

Get Product Price by id woocommerce

Add this code in function.php function woocommerce_price_by_id_wps( $atts ) {     $atts = shortcode_atts( array(         'id' => null,     ), $atts, 'bartag' );     $html = 'Add product id';     if( intval( $atts['id'] ) > 0 && function_exists( 'wc_get_product' ) ){          $_product = wc_get_product( $atts['id'] );          if (isset($_product) && !empty($_product)) {           $html = "price = " . $_product->get_price_html();          } else {           $html =  "Wrong product id";          }             }     return $html; } add_shortcode( 'woocommerce_price', 'woocommerce_price_by_id_wps' ); Shortcode  [woocommerce_price id="29"] ===========================================...

Woocommerce Get product from custom texonomy

<?php  $catid = $_POST['catid']; $designid = $_POST['designid']; $args = array( 'post_type' => 'product', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'design', 'field'    => 'slug', 'terms'    => $designid, ), array( 'taxonomy' => 'product_cat', 'field'    => 'term_id', 'terms'    => $catid, ), ), ); $query = new WP_Query( $args ); if( $query->have_posts() ) { while ( $query->have_posts() ) : $query->the_post(); ?> <?php wc_get_template_part( 'content', 'single-product' ); ?> <?php endwhile; } else { echo "No Product Found"; } ?>