Wednesday 15 April 2015

Woocommerce - Custom Shortcode - Add to Cart Button - How? -



Woocommerce - Custom Shortcode - Add to Cart Button - How? -

i working custom loop woocommerce. defined shortcode. code looks this:

<?php add_shortcode( 'kurse', 'ik_kurse' ); function ik_kurse( $atts, $content = null ) { // shortcode parameters extract(shortcode_atts(array( "per_page" => '' ), $atts)); // woocommerce global global $woocommerce; // create object ob_start(); // create query arguments array $query_args = array( 'posts_per_page' => '', 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', ); // add together meta_query query args $query_args['meta_query'] = array(); // check products stock status $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); // create new query $r = new wp_query($query_args); // if query homecoming results if ( $r->have_posts() ) { $content = '<ul class="rc_wc_rvp_product_list_widget">'; // start loop while ( $r->have_posts()) { $r->the_post(); global $product; $description= $prod_term->description; $content .= '***add cart button'; $content .= '<li>'; $content .= $product->get_sku(); ?> <br /><?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ); $content .= " | "; $content .= $product->get_price_html(); $content .= '</li>'; } $content .= '</ul>'; } // clean object $content .= ob_get_clean(); // homecoming whole content homecoming $content;}

i can not figure out how add together "add cart" button here, in line every single product. can help? give thanks you!

woocommerce shortcode

No comments:

Post a Comment