I've tried on my wordpress site to group multiple products and I have no idea why but I can't add products on cart.. I've tried to complete all the input for quantity, but nothing.. Any idea? On single product works..
Here is my grouped.php
<?php
/**
* Grouped product add to cart
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.1.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product, $post;
$parent_product_post = $post;
do_action( 'woocommerce_before_add_to_cart_form' ); ?>
<form class="cart" method="post" enctype='multipart/form-data'>
<div class="group_table">
<?php
foreach ( $grouped_products as $product_id ) :
$product = wc_get_product( $product_id );
$post = $product->post;
setup_postdata( $post );
?>
<div class="group-row">
<div class="quantity-row">
<?php if ( $product->is_sold_individually() || ! $product->is_purchasable() ) : ?>
<?php woocommerce_template_loop_add_to_cart(); ?>
<?php else : ?>
<?php
$quantites_required = true;
woocommerce_quantity_input( array( 'input_name' => 'quantity[' . $product_id . ']', 'input_value' => '0' ) );
?>
<?php endif; ?>
</div>
<div class="label">
<label>
<?php
if($product->is_visible()) {
echo '' . get_the_title() . '';
} else {
echo get_the_title();
}
?>
</label>
</div>
<?php do_action ( 'woocommerce_grouped_product_list_before_price', $product ); ?>
<div class="price">
<?php
echo ''.$product->get_price_html();
if ( $availability = $product->get_availability() ) {
$availability_html = empty( $availability['availability'] ) ? '' : '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</p>';
echo apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product );
}
?>
</div>
</div>
<?php
endforeach;
// Reset to parent grouped product
$post = $parent_product_post;
$product = wc_get_product( $parent_product_post->ID );
setup_postdata( $parent_product_post );
?>
</div>
<?php if($product) {?>
<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
<?php if ( $quantites_required ) : ?>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<button type="submit" class="single_add_to_cart_button button alt"><?php echo ''.$product->single_add_to_cart_text(); ?></button>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
<?php endif; ?>
<?php } else { ?>
<?php
$productid = intval( $_POST['data'] );
$product = get_product( $productid );
?>
<input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $product->id ); ?>" />
<?php if ( $quantites_required ) : ?>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<button type="submit" class="single_add_to_cart_button button alt"><?php echo ''.$product->single_add_to_cart_text(); ?></button>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
<?php endif; ?>
<?php }?>
</form>
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
UPDATE
Here is the problem fix..
woocommerce_quantity_input( array( 'input_name' => 'quantity[' . $product_id->get_id() . ']', 'input_value' => '0' ) );
The problem was at quantity.. before on quantity was all object of $product_id now is only the id of product, that was the problem..
Here is the problem fix..
woocommerce_quantity_input( array( 'input_name' => 'quantity[' . $product_id->get_id() . ']', 'input_value' => '0' ) );
The problem was at quantity.. before on quantity was all object of $product_id now is only the id of product, that was the problem..
Related
I want to combine two forms from two different plugins namely : Wp job manager (Plugin A) and Afj Company Listings (plugin B). plugin A has a form called job-submit.php (located in: public_html/wp-content/plugins/wp-job-manager/templates) which would like to combine with another form from Plugin B called company_listings-submit.php (located in: public_html/wp-content/plugins/afj-company-listings/templates).
What I have done is to add get method in the job-submit.php but didnt work:
get_afj_company_listings_template( 'company_listings-submit.php' )
job-submit.php
/**
Content for job submission ([submit_job_form]) shortcode.
This template can be overridden by copying it to yourtheme/job_manager/job-submit.php.
#see https://wpjobmanager.com/document/template-overrides/
#author Automattic
#package wp-job-manager
#category Template
#version 1.34.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
global $job_manager;
?>
" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data">
<?php
if ( isset( $resume_edit ) && $resume_edit ) {
printf( '<p><strong>' . esc_html__( "You are editing an existing job. %s", 'wp-job-manager' ) . '</strong></p>', '' . esc_html__( 'Create A New Job', 'wp-job-manager' ) . '' );
}
?>
<?php do_action( 'submit_job_form_start' ); ?>
<?php if ( apply_filters( 'submit_job_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php' ); ?>
<?php endif; ?>
<?php if ( job_manager_user_can_post_job() || job_manager_user_can_edit_job( $job_id ) ) : ?>
<!-- Job Information Fields -->
<?php do_action( 'submit_job_form_job_fields_start' ); ?>
<!-- MY OWN CODE HERE-----afj-company-listings/templates/company_listings-submit.php wp-content/plugins/wp-job-manager/templates-->
<?php get_job_manager_template( 'company_listings-submit.php' ); ?>
<?php foreach ( $job_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php echo esc_attr( $key ); ?> fieldset-type-<?php echo esc_attr( $field['type'] ); ?>">
<label for="<?php echo esc_attr( $key ); ?>"><?php echo wp_kses_post(
$field['label'] ) . wp_kses_post( apply_filters( 'submit_job_form_required_label',
$field['required'] ? '' : ' ' . __( '(optional)', 'wp-job-manager' ) . '', $field )
); ?>
">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-
field.php', [ 'key' => $key, 'field' => $field ] ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_job_fields_end' ); ?>
<!-- Company Information Fields -->
<?php if ( $company_fields ) : ?>
<h2><?php esc_html_e( 'Company Details', 'wp-job-manager' ); ?></h2>
<?php do_action( 'submit_job_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php echo esc_attr( $key ); ?> fieldset-type-<?php echo esc_attr( $field['type'] ); ?>">
<label for="<?php echo esc_attr( $key ); ?>"><?php echo wp_kses_post(
$field['label'] ) . wp_kses_post( apply_filters( 'submit_job_form_required_label',
$field['required'] ? '' : ' ' . __( '(optional)', 'wp-job-manager' ) . '', $field ) ); ?>
">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-field.php', [ 'key' => $key, 'field' => $field ] ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_company_fields_end' ); ?>
<?php endif; ?>
<?php do_action( 'submit_job_form_end' ); ?>
<p>
<input type="hidden" name="job_manager_form" value="<?php echo esc_attr( $form ); ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_job" class="button" value="<?php echo esc_attr(
$submit_button_text ); ?>" />
<?php
if ( isset( $can_continue_later ) && $can_continue_later ) {
echo '<input type="submit" name="save_draft" class="button secondary save_draft"
value="' . esc_attr__( 'Save Draft', 'wp-job-manager' ) . '" formnovalidate />';
}
?>
<span class="spinner" style="background-image: url(<?php echo esc_url( includes_url(
'images/spinner.gif' ) ); ?>);">
</p>
<?php else : ?>
<?php do_action( 'submit_job_form_disabled' ); ?>
<?php endif; ?>
company_listings-submit.php
" method="post" id="submit-company-form" class="job-manager-form" enctype="multipart/form-data">
<?php do_action( 'submit_company_form_start' ); ?>
<?php if ( apply_filters( 'submit_company_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php', array( 'class' => $class ), 'afj-company-listings', COMPANY_LISTINGS_PLUGIN_DIR . '/templates/' ); ?>
<?php endif; ?>
<?php if ( company_listings_user_can_post_company() ) : ?>
<!-- Company Fields -->
<?php do_action( 'submit_company_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php esc_attr_e( $key ); ?>">
<label for="<?php esc_attr_e( $key ); ?>"><?php echo $field['label'] . apply_filters( 'submit_company_form_required_label', $field['required'] ? '' : ' <small>' . __( '(optional)', 'afj-company-listings' ) . '</small>', $field ); ?></label>
<div class="field">
<?php $class->get_field_template( $key, $field ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_company_form_company_fields_end' ); ?>
<p>
<?php wp_nonce_field( 'submit_form_posted' ); ?>
<input type="hidden" name="company_listings_form" value="<?php echo $form; ?>" />
<input type="hidden" name="company_id" value="<?php echo esc_attr( $company_id ); ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_company" class="button" value="<?php esc_attr_e( $submit_button_text ); ?>" />
</p>
<?php else : ?>
<?php do_action( 'submit_company_form_disabled' ); ?>
<?php endif; ?>
<?php do_action( 'submit_company_form_end' ); ?>
I am working on a woo-commerce theme and it's good but on the checkout page clients want's to change the order of some blocks. so he wanted to move payment methods before order summary. I did that by adding the code in function.php which is given below. The code works fine but after adding the code i can't see order summary on checkout page. I can't see Subtotal, Shipment and Total Cost. I don't know what is wrong with this code. please help me out with this.
add_action( 'woocommerce_checkout_order_review', 'reordering_checkout_order_review', 1 );
function reordering_checkout_order_review(){
remove_action('woocommerce_checkout_order_review','woocommerce_checkout_payment', 20 );
add_action( 'woocommerce_checkout_order_review', 'custom_checkout_payment', 8 );
add_action( 'woocommerce_checkout_order_review', 'after_custom_checkout_payment', 9 );
add_action( 'woocommerce_checkout_order_review', 'custom_checkout_place_order', 20 );
}
function after_custom_checkout_payment() {
?>
<div id="before-order-table" class="woocommerce-checkout-custom-text">
<h3><?php _e("Your order", "woocommerce"); ?></h3>
<p><?php /* _e("I have accepted the terms and bla bla bla", "woocommerce"); */?></p>
</div>
<?php
}
function custom_checkout_payment() {
$checkout = WC()->checkout();
if ( WC()->cart->needs_payment() ) {
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
WC()->payment_gateways()->set_current_gateway( $available_gateways );
} else {
$available_gateways = array();
}
if ( ! is_ajax() ) {
// do_action( 'woocommerce_review_order_before_payment' );
}
?>
<div id="payment" class="woocommerce-checkout-payment-gateways">
<?php if ( WC()->cart->needs_payment() ) : ?>
<ul class="wc_payment_methods payment_methods methods">
<?php
if ( ! empty( $available_gateways ) ) {
foreach ( $available_gateways as $gateway ) {
wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
}
} else {
echo '<li class="woocommerce-notice woocommerce-notice--info woocommerce-info">';
echo apply_filters( 'woocommerce_no_available_payment_methods_message', WC()->customer->get_billing_country() ? esc_html__( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) : esc_html__( 'Please fill in your details above to see available payment methods.', 'woocommerce' ) ) . '</li>'; // #codingStandardsIgnoreLine
}
?>
</ul>
<?php endif; ?>
</div>
<?php
}
function custom_checkout_place_order() {
$checkout = WC()->checkout();
$order_button_text = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) );
?>
<div id="payment-place-order" class="woocommerce-checkout-place-order">
<div class="form-row place-order">
<noscript>
<?php esc_html_e( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ); ?>
<br/><button type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'woocommerce' ); ?>"><?php esc_html_e( 'Update totals', 'woocommerce' ); ?></button>
</noscript>
<?php wc_get_template( 'checkout/terms.php' ); ?>
<?php do_action( 'woocommerce_review_order_before_submit' ); ?>
<?php echo apply_filters( 'woocommerce_order_button_html', '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>' ); // #codingStandardsIgnoreLine ?>
<?php do_action( 'woocommerce_review_order_after_submit' ); ?>
<?php wp_nonce_field( 'woocommerce-process_checkout', 'woocommerce-process-checkout-nonce' ); ?>
</div>
</div>
<?php
if ( ! is_ajax() ) {
do_action( 'woocommerce_review_order_after_payment' );
}
}
You can also check with:
add_filter( 'woocommerce_checkout_fields' , 'custom_order_comments_checkout_fields' );
function custom_order_comments_checkout_fields( $fields ) {
if ( !WC()->cart->is_empty()):
$output = '';
$count = 0;
$cart_item_count = WC()->cart->get_cart_contents_count();
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ):
$count++;
// Displaying the product title
$output .= 'Product title: ' . $cart_item['data']->post->post_title;
// New line (for next item)
if($count < $cart_item_count)
$output .= '';
endforeach;
$fields['order']['order_comments']['default'] = $output;
endif;
return $fields;
}
how to query woocommerce shipping method tax price ?
Porblem i don't tax + prive query!
Price query:
<?php if($method->cost > 0) : ?>+<span style="font-weight: normal"><?= $method->cost ?> Ft</span><?php endif; ?>
</label>
</div>
My code is:
<h2>Átvételi mód</h2>
<?php
$packages = WC()->shipping->get_packages();
$first = true;
foreach ($packages as $i => $package) {
$chosen_method = isset(WC()->session->chosen_shipping_methods[$i]) ? WC()->session->chosen_shipping_methods[$i] : '';
$product_names = array();
if (sizeof($packages) > 1) {
foreach ($package['contents'] as $item_id => $values) {
$product_names[$item_id] = $values['data']->get_name() . ' ×' . $values['quantity'];
}
$product_names = apply_filters('woocommerce_shipping_package_details_array', $product_names, $package);
}
/** #var WC_Shipping_Rate[] $available_methods */
$available_methods = $package['rates'];
$show_package_details = sizeof( $packages ) > 1;
$package_name = apply_filters( 'woocommerce_shipping_package_name', sprintf( _nx( 'Shipping', 'Shipping %d', ( $i + 1 ), 'shipping packages', 'woocommerce' ), ( $i + 1 ) ), $i, $package );
?>
<div class="shipping atvetelimod">
<td data-title="<?php echo esc_attr( $package_name ); ?>">
<?php if ( 1 < count( $available_methods ) ) : ?>
<div id="shipping_method row">
<?php
foreach ( $available_methods as $method ) : ?>
<div class="col-lg-6 balraszoveg">
<div class="jobbelvalaszto">
<label class="checkjel">
<input class="legyenelottefeher" type="radio" name="shipping_method[<?= $i ?>]" data-index="<?= $i ?>" id="shipping_method_<?= $i ?>_<?= sanitize_title( $method->id ) ?>" value="<?= esc_attr( $method->id ) ?>" class="shipping_method" <?= checked( $method->id, $chosen_method, false ) ?> />
</label>
</div>
<label class="jobboldaliszoveg" for="shipping_method_<?= $i ?>_<?= sanitize_title( $method->id ) ?>">
<strong><?= $method->get_label() ?></strong><br />
<?php if($method->cost > 0) : ?>+<span style="font-weight: normal"><?= $method->cost ?> Ft</span><?php endif; ?>
</label>
</div>
<?php endforeach; ?>
</div>
<?php elseif ( 1 === count( $available_methods ) ) : ?>
<?php
$method = current( $available_methods );
printf( '%3$s <input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d" value="%2$s" class="shipping_method" />', $index, esc_attr( $method->id ), wc_cart_totals_shipping_method_label( $method ) );
do_action( 'woocommerce_after_shipping_rate', $method, $index );
?>
<?php elseif ( WC()->customer->has_calculated_shipping() ) : ?>
<?php echo apply_filters( is_cart() ? 'woocommerce_cart_no_shipping_available_html' : 'woocommerce_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) ); ?>
<?php elseif ( ! is_cart() ) : ?>
<?php echo wpautop( __( 'Enter your full address to see shipping costs.', 'woocommerce' ) ); ?>
<?php endif; ?>
<?php if ( $show_package_details ) : ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php endif; ?>
<?php if ( ! empty( $show_shipping_calculator ) ) : ?>
<?php woocommerce_shipping_calculator(); ?>
<?php endif; ?>
</td>
</div>
<?php }; ?>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
new here and have an issue. I'm trying to find a parse error in the code. It says "line 51" in the message, but I've tried deleting, tags and no resolve. Can someone point me in the right direction as I'm really new to php
<?php
/**
* Variable product add to cart
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $product;
$attribute_keys = array_keys( $attributes );
do_action( 'woocommerce_before_add_to_cart_form' ); ?>
<form class="variations_form cart" method="post" enctype='multipart/form-data' data-product_id="<?php echo absint( $product->id ); ?>" data-product_variations="<?php echo esc_attr( json_encode( $available_variations ) ) ?>">
<?php do_action( 'woocommerce_before_variations_form' ); ?>
<?php if ( empty( $available_variations ) && false !== $available_variations ) : ?>
<p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?></p>
<?php else : ?>
<table class="variations" cellspacing="0">
<tbody>
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
<tr>
<td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
<td class="value">
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected, 'class' => 'sc-combobox' ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
<div class="single_variation_wrap" style="display:none;">
<?php
/**
* woocommerce_before_single_variation Hook
*/
do_action( 'woocommerce_before_single_variation' );
<div class="single_variation clearfix"></div> <<--THIS IS LINE 51
<div class="variations_button">
<?php woocommerce_quantity_input( array( 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( $_POST['quantity'] ) : 1 ) ); ?>
<button type="submit" class="sc-button single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
<input type="hidden" name="add-to-cart" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="product_id" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="variation_id" class="variation_id" value="" />
</div>
/**
* woocommerce_after_single_variation Hook
*/
do_action( 'woocommerce_after_single_variation' );
?>
</div>
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
<?php else : ?>
<p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'scalia' ); ?></p>
<?php endif; ?>
<?php do_action( 'woocommerce_after_variations_form' ); ?>
</form>
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
In this block you're opening a PHP block twice without closing a previous one.
<?php
/**
* woocommerce_before_single_variation Hook
*/
do_action( 'woocommerce_before_single_variation' );
<div class="single_variation clearfix"></div> <<--THIS IS LINE 51
<div class="variations_button">
<?php woocommerce_quantity_input
I'm trying to figure out on how to populate my custom ordering inside my custom template page.
Here is my work in progress. So far the output shows a select box with empty values. When I check the view source i saw this error.
Warning: Invalid argument supplied for foreach() in C:\Users\Noel\Desktop\xampp\htdocs\lumiere\wp-content\themes\klasik\lumiere-products-page.php on line 23
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'product_cat' => 'Lumiere', 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<?php //Woocommerce Custom Ordering ?>
<form class="woocommerce-ordering" method="get">
<select name="orderby" class="orderby">
<?php foreach ( $catalog_orderby_options as $id => $name ) : ?>
<option value="<?php echo esc_attr( $id ); ?>" <?php selected( $orderby, $id ); ?>><?php echo esc_html( $name ); ?></option>
<?php endforeach; ?>
</select>
<?php
// Keep query string vars intact
foreach ( $_GET as $key => $val ) {
if ( 'orderby' === $key || 'submit' === $key ) {
continue;
}
if ( is_array( $val ) ) {
foreach( $val as $innerVal ) {
echo '<input type="hidden" name="' . esc_attr( $key ) . '[]" value="' . esc_attr( $innerVal ) . '" />';
}
} else {
echo '<input type="hidden" name="' . esc_attr( $key ) . '" value="' . esc_attr( $val ) . '" />';
}
}
?>
</form>
<li class="product product-items ">
<div class="product-item">
<?php woocommerce_show_product_sale_flash( $post, $product ); ?>
<div class="product-thumbnail">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" />'; ?>
</div>
<div class="product-info">
<h3>
<?php the_title(); ?>
</h3>
<h4 class="product-category-title">
<?php
$size = sizeof( get_the_terms( $post->ID, 'product_cat' ) );
echo $product->get_categories( ', ', '<span class="posted_in">' . ' ', '.</span>' );
?>
</h4>
<?php echo $product->get_sku(); ?>
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
<?php if ( $price_html = $product->get_price_html() ) : ?>
<span class="price"><?php echo $price_html; ?></span>
<?php endif; ?>
<div class="product-rating">
<?php if ($average = $product->get_average_rating()) : ?>
<?php echo '<div class="star-rating" title="'.sprintf(__( 'Rated %s out of 5', 'woocommerce' ), $average).'"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', 'woocommerce' ).'</span></div>'; ?>
<?php endif; ?>
</div>
<?php woocommerce_template_loop_add_to_cart( $loop->post, $product ); ?>
</div>
</div>
</li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul><!--/.products-->