New shipping system to delete with multiple rates per gateway

This commit is contained in:
Mike Jolley 2011-09-02 15:42:04 +01:00
parent 9004e2ef8b
commit 63ec2b001f
19 changed files with 125 additions and 108 deletions

View File

@ -21,7 +21,7 @@ function woocommerce_attributes() {
if (isset($_POST['add_new_attribute']) && $_POST['add_new_attribute']) : if (isset($_POST['add_new_attribute']) && $_POST['add_new_attribute']) :
$attribute_name = (string) strtolower(sanitize_title($_POST['attribute_name'])); $attribute_name = (string) sanitize_title($_POST['attribute_name']);
$attribute_type = (string) $_POST['attribute_type']; $attribute_type = (string) $_POST['attribute_type'];
$attribute_label = (string) $_POST['attribute_label']; $attribute_label = (string) $_POST['attribute_label'];

View File

@ -353,7 +353,7 @@ function woocommerce_custom_order_columns($column) {
echo '–'; echo '–';
endif; endif;
if ($order->shipping_metho) : if ($order->shipping_method) :
echo '<small class="meta">' . __('Shipped via ', 'woothemes') . $order->shipping_method . '</small>'; echo '<small class="meta">' . __('Shipped via ', 'woothemes') . $order->shipping_method . '</small>';
endif; endif;
break; break;

View File

@ -585,7 +585,7 @@ function woocommerce_update_options($options) {
$state = end($cr); $state = end($cr);
endif; endif;
$counties_array[$country][] = $state; $counties_array[trim($country)][] = trim($state);
endforeach; endforeach;
@ -840,51 +840,6 @@ function woocommerce_admin_fields($options) {
<p><a href="#" class="add button"><?php _e('+ Add Tax Rule', 'woothemes'); ?></a></p> <p><a href="#" class="add button"><?php _e('+ Add Tax Rule', 'woothemes'); ?></a></p>
</td> </td>
</tr> </tr>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(function() {
jQuery(".country_multiselect").multiselect({
noneSelectedText: '<?php _e('Select countries/states', 'woothemes'); ?>',
selectedList: 4
});
jQuery('#tax_rates a.add').live('click', function(){
var size = jQuery('.taxrows .taxrow').size();
// Add the row
jQuery('<div class="taxrow">\
<select name="tax_country[' + size + '][]" title="Country" class="country_multiselect" size="10" multiple="multiple"><?php echo woocommerce_countries::country_multiselect_options('',true); ?></select>\
<select name="tax_class[' + size + ']" title="Tax Class"><option value=""><?php _e('Standard Rate', 'woothemes'); ?></option><?php
if ($tax_classes) foreach ($tax_classes as $class) :
echo '<option value="'.sanitize_title($class).'">'.$class.'</option>';
endforeach;
?></select>\
<input type="text" class="text" name="tax_rate[' + size + ']" title="<?php _e('Rate', 'woothemes'); ?>" placeholder="<?php _e('Rate', 'woothemes'); ?>" maxlength="8" />% \
<label class="checkbox"><input type="checkbox" name="tax_shipping[' + size + ']" checked="checked" /> <?php _e('Apply to shipping', 'woothemes'); ?></label><a href="#" class="remove button">&times;</a>\
</div>').appendTo('#tax_rates div.taxrows');
// Multiselect
jQuery(".country_multiselect").multiselect({
noneSelectedText: '<?php _e('Select countries/states', 'woothemes'); ?>',
selectedList: 4
});
return false;
});
jQuery('#tax_rates a.remove').live('click', function(){
var answer = confirm("<?php _e('Delete this rule?', 'woothemes'); ?>");
if (answer) {
jQuery('input', jQuery(this).parent()).val('');
jQuery(this).parent().hide();
}
return false;
});
});
/* ]]> */
</script>
<?php <?php
break; break;
case "shipping_options" : case "shipping_options" :
@ -994,6 +949,46 @@ function woocommerce_admin_fields($options) {
} }
}).change(); }).change();
// Country Multiselect boxes
jQuery(".country_multiselect").multiselect({
noneSelectedText: '<?php _e('Select countries/states', 'woothemes'); ?>',
selectedList: 4
});
// Tax
jQuery('#tax_rates a.add').live('click', function(){
var size = jQuery('.taxrows .taxrow').size();
// Add the row
jQuery('<div class="taxrow">\
<select name="tax_country[' + size + '][]" title="Country" class="country_multiselect" size="10" multiple="multiple"><?php echo woocommerce_countries::country_multiselect_options('',true); ?></select>\
<select name="tax_class[' + size + ']" title="Tax Class"><option value=""><?php _e('Standard Rate', 'woothemes'); ?></option><?php
if ($tax_classes) foreach ($tax_classes as $class) :
echo '<option value="'.sanitize_title($class).'">'.$class.'</option>';
endforeach;
?></select>\
<input type="text" class="text" name="tax_rate[' + size + ']" title="<?php _e('Rate', 'woothemes'); ?>" placeholder="<?php _e('Rate', 'woothemes'); ?>" maxlength="8" />% \
<label class="checkbox"><input type="checkbox" name="tax_shipping[' + size + ']" checked="checked" /> <?php _e('Apply to shipping', 'woothemes'); ?></label><a href="#" class="remove button">&times;</a>\
</div>').appendTo('#tax_rates div.taxrows');
// Multiselect
jQuery(".country_multiselect").multiselect({
noneSelectedText: '<?php _e('Select countries/states', 'woothemes'); ?>',
selectedList: 4
});
return false;
});
jQuery('#tax_rates a.remove').live('click', function(){
var answer = confirm("<?php _e('Delete this rule?', 'woothemes'); ?>");
if (answer) {
jQuery('input', jQuery(this).parent()).val('');
jQuery(this).parent().hide();
}
return false;
});
}); });
</script> </script>
<?php <?php

View File

@ -416,13 +416,7 @@ ul.recent-orders li .refunded, ul.recent-orders li .cancelled {
float: left; float: left;
} }
/* Settings */ /* Settings */
.woocommerce table.shippingrows {
border: 0;
width: 100%;
}
.woocommerce table.shippingrows td, .woocommerce table.shippingrows th { .woocommerce table.shippingrows td, .woocommerce table.shippingrows th {
padding: 4px 4px 4px 0 !important;
border: 0 !important;
vertical-align: middle; vertical-align: middle;
} }
.woocommerce table.shippingrows td a.remove { .woocommerce table.shippingrows td a.remove {

View File

@ -453,13 +453,7 @@ ul.recent-orders {
} }
/* Settings */ /* Settings */
.woocommerce table.shippingrows { .woocommerce table.shippingrows td, .woocommerce table.shippingrows th {
border: 0;
width: 100%;
}
.woocommerce table.shippingrows td,.woocommerce table.shippingrows th {
padding: 4px 4px 4px 0 !important;
border: 0 !important;
vertical-align: middle; vertical-align: middle;
} }
.woocommerce table.shippingrows td a.remove { .woocommerce table.shippingrows td a.remove {

View File

@ -303,7 +303,7 @@ jQuery(function(){
var attr_val = attributes[attr_name]; var attr_val = attributes[attr_name];
if(attr_name == current_attr_name) { if(attr_name == current_attr_name) {
current_attr_select.find('option:contains("'+attr_val+'")').removeAttr('disabled'); current_attr_select.find('option[value="'+attr_val+'"]').removeAttr('disabled');
} }
} }
} }

View File

@ -268,6 +268,9 @@ class woocommerce_checkout {
if (woocommerce_cart::ship_to_billing_address_only()) $this->posted['shiptobilling'] = 'true'; if (woocommerce_cart::ship_to_billing_address_only()) $this->posted['shiptobilling'] = 'true';
// Update shipping method to posted
$_SESSION['_chosen_shipping_method'] = $this->posted['shipping_method'];
// Billing Information // Billing Information
foreach ($this->billing_fields as $field) : foreach ($this->billing_fields as $field) :
@ -576,6 +579,12 @@ class woocommerce_checkout {
endif; endif;
endif; endif;
// Get better formatted shipping method (title/label)
$shipping_method = $this->posted['shipping_method'];
if (isset($available_methods) && isset($available_methods[$this->posted['shipping_method']])) :
$shipping_method = $available_methods[$this->posted['shipping_method']]->title;
endif;
// Update order meta // Update order meta
update_post_meta( $order_id, '_billing_first_name', $this->posted['billing-first_name']); update_post_meta( $order_id, '_billing_first_name', $this->posted['billing-first_name']);
update_post_meta( $order_id, '_billing_last_name', $this->posted['billing-last_name']); update_post_meta( $order_id, '_billing_last_name', $this->posted['billing-last_name']);
@ -597,7 +606,7 @@ class woocommerce_checkout {
update_post_meta( $order_id, '_shipping_postcode', $shipping_postcode); update_post_meta( $order_id, '_shipping_postcode', $shipping_postcode);
update_post_meta( $order_id, '_shipping_country', $shipping_country); update_post_meta( $order_id, '_shipping_country', $shipping_country);
update_post_meta( $order_id, '_shipping_state', $shipping_state); update_post_meta( $order_id, '_shipping_state', $shipping_state);
update_post_meta( $order_id, '_shipping_method', $this->posted['shipping_method']); update_post_meta( $order_id, '_shipping_method', $shipping_method);
update_post_meta( $order_id, '_payment_method', $this->posted['payment_method']); update_post_meta( $order_id, '_payment_method', $this->posted['payment_method']);
update_post_meta( $order_id, '_order_subtotal', number_format(woocommerce_cart::$subtotal_ex_tax, 2, '.', '')); update_post_meta( $order_id, '_order_subtotal', number_format(woocommerce_cart::$subtotal_ex_tax, 2, '.', ''));
update_post_meta( $order_id, '_order_shipping', number_format(woocommerce_cart::$shipping_total, 2, '.', '')); update_post_meta( $order_id, '_order_shipping', number_format(woocommerce_cart::$shipping_total, 2, '.', ''));

View File

@ -412,7 +412,7 @@ class woocommerce_countries {
),*/ ),*/
'US' => array( 'US' => array(
'AL' => 'Alabama' , 'AL' => 'Alabama' ,
'AK' => 'Alaska ' , 'AK' => 'Alaska' ,
'AZ' => 'Arizona' , 'AZ' => 'Arizona' ,
'AR' => 'Arkansas' , 'AR' => 'Arkansas' ,
'CA' => 'California' , 'CA' => 'California' ,

View File

@ -79,6 +79,7 @@ class woocommerce_order {
'order_subtotal' => '', 'order_subtotal' => '',
'order_discount' => '', 'order_discount' => '',
'order_tax' => '', 'order_tax' => '',
'order_shipping' => '',
'order_shipping_tax' => '', 'order_shipping_tax' => '',
'order_total' => '' 'order_total' => ''
); );
@ -156,8 +157,11 @@ class woocommerce_order {
$shipping = woocommerce_price($this->order_shipping); $shipping = woocommerce_price($this->order_shipping);
if ($this->order_shipping_tax > 0) : if ($this->order_shipping_tax > 0) :
$shipping .= sprintf(__(' <small>(ex. tax) via %s</small>', 'woothemes'), ucwords($this->shipping_method)); $tax_text = __('(ex. tax) ', 'woothemes');
else :
$tax_text = '';
endif; endif;
$shipping .= sprintf(__(' <small>%svia %s</small>', 'woothemes'), $tax_text, ucwords($this->shipping_method));
else : else :
$shipping = __('Free!', 'woothemes'); $shipping = __('Free!', 'woothemes');

View File

@ -177,7 +177,7 @@ class flat_rate extends woocommerce_shipping_method {
public function process_admin_options() { public function process_admin_options() {
if(isset($_POST['woocommerce_flat_rate_tax_status'])) update_option('woocommerce_flat_rate_tax_status', 'yes'); else update_option('woocommerce_flat_rate_tax_status', 'no'); if(isset($_POST['woocommerce_flat_rate_tax_status'])) update_option('woocommerce_flat_rate_tax_status', woocommerce_clean($_POST['woocommerce_flat_rate_tax_status'])); else @delete_option('woocommerce_flat_rate_tax_status');
if(isset($_POST['woocommerce_flat_rate_enabled'])) update_option('woocommerce_flat_rate_enabled', 'yes'); else update_option('woocommerce_flat_rate_enabled', 'no'); if(isset($_POST['woocommerce_flat_rate_enabled'])) update_option('woocommerce_flat_rate_enabled', 'yes'); else update_option('woocommerce_flat_rate_enabled', 'no');

View File

@ -18,7 +18,6 @@ class free_shipping extends woocommerce_shipping_method {
$this->min_amount = get_option('woocommerce_free_shipping_minimum_amount'); $this->min_amount = get_option('woocommerce_free_shipping_minimum_amount');
$this->availability = get_option('woocommerce_free_shipping_availability'); $this->availability = get_option('woocommerce_free_shipping_availability');
$this->countries = get_option('woocommerce_free_shipping_countries'); $this->countries = get_option('woocommerce_free_shipping_countries');
if (isset($_SESSION['_chosen_method_id']) && $_SESSION['_chosen_method_id']==$this->id) $this->chosen = true;
add_action('woocommerce_update_options', array(&$this, 'process_admin_options')); add_action('woocommerce_update_options', array(&$this, 'process_admin_options'));
add_option('woocommerce_free_shipping_availability', 'all'); add_option('woocommerce_free_shipping_availability', 'all');
@ -53,7 +52,7 @@ class free_shipping extends woocommerce_shipping_method {
<tr valign="top"> <tr valign="top">
<th scope="row" class="titledesc"><?php _e('Minimum Order Amount', 'woothemes') ?></th> <th scope="row" class="titledesc"><?php _e('Minimum Order Amount', 'woothemes') ?></th>
<td class="forminp"> <td class="forminp">
<input type="text" name="woocommerce_free_shipping_minimum_amount" id="woocommerce_free_shipping_minimum_amount" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_free_shipping_minimum_amount')) echo $value; else echo 'Free Shipping'; ?>" /> <span class="description"><?php _e('Users will need to spend this amount to get free shipping. Leave blank to disable.', 'woothemes') ?></span> <input type="text" name="woocommerce_free_shipping_minimum_amount" id="woocommerce_free_shipping_minimum_amount" style="min-width:50px;" value="<?php if ($value = get_option('woocommerce_free_shipping_minimum_amount')) echo $value; ?>" /> <span class="description"><?php _e('Users will need to spend this amount to get free shipping. Leave blank to disable.', 'woothemes') ?></span>
</td> </td>
</tr> </tr>
<tr valign="top"> <tr valign="top">

View File

@ -49,23 +49,46 @@ class woocommerce_shipping {
if (self::$enabled=='yes') : if (self::$enabled=='yes') :
$_available_methods = array(); $_available_methods = array();
foreach ( self::$shipping_methods as $method ) : foreach ( self::$shipping_methods as $shipping_method ) :
if ($method->is_available()) $_available_methods[$method->id] = $method; if ($shipping_method->is_available()) :
$shipping_method->calculate_shipping();
// If available, put available methods/rates in the array
if ($shipping_method->multiple_rates) :
foreach ($shipping_method->rates as $rate) :
$method = $rate;
$_available_methods[$method->id] = $method;
endforeach;
else :
$method = $shipping_method;
$_available_methods[$method->id] = $method;
endif;
endif;
endforeach; endforeach;
return $_available_methods; return $_available_methods;
endif; endif;
} }
function reset_shipping_methods() { function reset_shipping_methods() {
foreach ( self::$shipping_methods as $method ) : foreach ( self::$shipping_methods as $shipping_method ) :
$method->chosen = false; $shipping_method->shipping_total = 0;
$method->shipping_total = 0; $shipping_method->shipping_tax = 0;
$method->shipping_tax = 0; $shipping_method->rates = array();
endforeach; endforeach;
} }
@ -78,7 +101,7 @@ class woocommerce_shipping {
self::$shipping_label = null; self::$shipping_label = null;
$_cheapest_fee = ''; $_cheapest_fee = '';
$_cheapest_method = ''; $_cheapest_method = '';
if (isset($_SESSION['_chosen_method_id'])) $chosen_method = $_SESSION['_chosen_method_id']; else $chosen_method = ''; if (isset($_SESSION['_chosen_shipping_method'])) $chosen_method = $_SESSION['_chosen_shipping_method']; else $chosen_method = '';
$calc_cheapest = false; $calc_cheapest = false;
if (!$chosen_method || empty($chosen_method)) $calc_cheapest = true; if (!$chosen_method || empty($chosen_method)) $calc_cheapest = true;
@ -89,15 +112,14 @@ class woocommerce_shipping {
if (sizeof($_available_methods)>0) : if (sizeof($_available_methods)>0) :
foreach ($_available_methods as $method) : foreach ($_available_methods as $method_id => $method) :
$method->calculate_shipping();
$fee = $method->shipping_total; $fee = $method->shipping_total;
if ($fee < $_cheapest_fee || !is_numeric($_cheapest_fee)) : if ($fee < $_cheapest_fee || !is_numeric($_cheapest_fee)) :
$_cheapest_fee = $fee; $_cheapest_fee = $fee;
$_cheapest_method = $method->id; $_cheapest_method = $method_id;
endif; endif;
endforeach; endforeach;
// Default to cheapest // Default to cheapest
@ -107,7 +129,7 @@ class woocommerce_shipping {
if ($chosen_method) : if ($chosen_method) :
$_available_methods[$chosen_method]->choose(); $_SESSION['_chosen_shipping_method'] = $chosen_method;
self::$shipping_total = $_available_methods[$chosen_method]->shipping_total; self::$shipping_total = $_available_methods[$chosen_method]->shipping_total;
self::$shipping_tax = $_available_methods[$chosen_method]->shipping_tax; self::$shipping_tax = $_available_methods[$chosen_method]->shipping_tax;
self::$shipping_label = $_available_methods[$chosen_method]->title; self::$shipping_label = $_available_methods[$chosen_method]->title;
@ -120,6 +142,7 @@ class woocommerce_shipping {
} }
function reset_shipping() { function reset_shipping() {
unset($_SESSION['_chosen_shipping_method']);
self::$shipping_total = 0; self::$shipping_total = 0;
self::$shipping_tax = 0; self::$shipping_tax = 0;
self::$shipping_label = null; self::$shipping_label = null;

View File

@ -16,13 +16,14 @@ class woocommerce_shipping_method {
var $availability; var $availability;
var $countries; var $countries;
var $type; var $type;
var $cost = 0;
var $fee = 0; var $fee = 0;
var $min_amount = null; var $min_amount = null;
var $enabled = false; var $enabled = false;
var $chosen = false;
var $shipping_total = 0; var $shipping_total = 0;
var $shipping_tax = 0; var $shipping_tax = 0;
var $cost = 0; // Stores cost if theres only one
var $multiple_rates = false;
var $rates = array(); // When a method has more than one cost/choice it will be in this array of titles/costs
public function is_available() { public function is_available() {
@ -55,17 +56,7 @@ class woocommerce_shipping_method {
return $fee; return $fee;
endif; endif;
} }
public function is_chosen() {
if ($this->chosen) return true;
return false;
}
public function choose() {
$this->chosen = true;
$_SESSION['_chosen_method_id'] = $this->id;
}
public function admin_options() {} public function admin_options() {}
public function process_admin_options() {} public function process_admin_options() {}

View File

@ -26,7 +26,7 @@ function woocommerce_cart( $atts ) {
// Update Shipping // Update Shipping
elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && woocommerce::verify_nonce('cart')) : elseif (isset($_POST['calc_shipping']) && $_POST['calc_shipping'] && woocommerce::verify_nonce('cart')) :
unset($_SESSION['_chosen_method_id']); unset($_SESSION['_chosen_shipping_method']);
$country = $_POST['calc_shipping_country']; $country = $_POST['calc_shipping_country'];
$state = $_POST['calc_shipping_state']; $state = $_POST['calc_shipping_state'];

View File

@ -29,7 +29,7 @@
echo '<option value="'.$method->id.'" '; echo '<option value="'.$method->id.'" ';
if ($method->chosen) echo 'selected="selected"'; if ($method->id==$_SESSION['_chosen_shipping_method']) echo 'selected="selected"';
echo '>'.$method->title.' &ndash; '; echo '>'.$method->title.' &ndash; ';

View File

@ -40,7 +40,7 @@ function woocommerce_ajax_update_order_review() {
die(); die();
endif; endif;
if (isset($_POST['shipping_method'])) $_SESSION['_chosen_method_id'] = $_POST['shipping_method']; if (isset($_POST['shipping_method'])) $_SESSION['_chosen_shipping_method'] = $_POST['shipping_method'];
if (isset($_POST['country'])) woocommerce_customer::set_country( $_POST['country'] ); if (isset($_POST['country'])) woocommerce_customer::set_country( $_POST['country'] );
if (isset($_POST['state'])) woocommerce_customer::set_state( $_POST['state'] ); if (isset($_POST['state'])) woocommerce_customer::set_state( $_POST['state'] );

View File

@ -25,6 +25,9 @@ add_filter( 'parse_query', 'woocommerce_parse_query' );
function woocommerce_parse_query( $q ) { function woocommerce_parse_query( $q ) {
// Apply to main loop only
remove_filter( 'parse_query', 'woocommerce_parse_query' );
// Only apply to product categories, the product post archive, the shop page, and product tags // Only apply to product categories, the product post archive, the shop page, and product tags
if (true == $q->query_vars['suppress_filters'] || (!$q->is_tax( 'product_cat' ) && !$q->is_post_type_archive( 'product' ) && !$q->is_page( get_option('woocommerce_shop_page_id') ) && !$q->is_tax( 'product_tag' ))) return; if (true == $q->query_vars['suppress_filters'] || (!$q->is_tax( 'product_cat' ) && !$q->is_post_type_archive( 'product' ) && !$q->is_page( get_option('woocommerce_shop_page_id') ) && !$q->is_tax( 'product_tag' ))) return;
@ -86,9 +89,6 @@ function woocommerce_parse_query( $q ) {
$q->set( 'post__in', $woocommerce_query['post__in'] ); $q->set( 'post__in', $woocommerce_query['post__in'] );
$q->set( 'posts_per_page', apply_filters('loop_shop_per_page', get_option('posts_per_page')) ); $q->set( 'posts_per_page', apply_filters('loop_shop_per_page', get_option('posts_per_page')) );
// Apply to main loop only
remove_filter( 'parse_query', 'woocommerce_parse_query' );
// We're on a shop page so queue the woocommerce_get_products_in_view function // We're on a shop page so queue the woocommerce_get_products_in_view function
add_action('wp', 'woocommerce_get_products_in_view', 2); add_action('wp', 'woocommerce_get_products_in_view', 2);
} }

View File

@ -344,8 +344,15 @@ if (!function_exists('woocommerce_variable_add_to_cart')) {
<td><select id="<?php echo sanitize_title($name); ?>" name="tax_<?php echo sanitize_title($name); ?>"> <td><select id="<?php echo sanitize_title($name); ?>" name="tax_<?php echo sanitize_title($name); ?>">
<option value=""><?php echo __('Choose an option', 'woothemes') ?>&hellip;</option> <option value=""><?php echo __('Choose an option', 'woothemes') ?>&hellip;</option>
<?php if(is_array($options)) : ?> <?php if(is_array($options)) : ?>
<?php foreach ($options as $option) : $option_term = get_term_by('slug', $option, woocommerce::attribute_name($name)); ?> <?php foreach ($options as $option) :
<?php echo '<option value="'.$option.'">'.$option_term->name.'</option>'; ?> $option_term = get_term_by('slug', $option, woocommerce::attribute_name($name));
if (!is_wp_error($option_term) && isset($option_term->name)) :
$term_name = $option_term->name;
else :
$term_name = $option;
endif;
?>
<?php echo '<option value="'.$option.'">'.$term_name.'</option>'; ?>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif;?> <?php endif;?>
</td> </td>
@ -498,7 +505,7 @@ if (!function_exists('woocommerce_get_product_thumbnail')) {
**/ **/
if (!function_exists('woocommerce_output_related_products')) { if (!function_exists('woocommerce_output_related_products')) {
function woocommerce_output_related_products() { function woocommerce_output_related_products() {
// 4 Related Products in 4 columns // 2 Related Products in 2 columns
woocommerce_related_products( 2, 2 ); woocommerce_related_products( 2, 2 );
} }
} }
@ -506,10 +513,9 @@ if (!function_exists('woocommerce_output_related_products')) {
if (!function_exists('woocommerce_related_products')) { if (!function_exists('woocommerce_related_products')) {
function woocommerce_related_products( $posts_per_page = 4, $post_columns = 4, $orderby = 'rand' ) { function woocommerce_related_products( $posts_per_page = 4, $post_columns = 4, $orderby = 'rand' ) {
global $_product, $columns, $per_page; global $_product, $columns;
// Pass vars to loop // Pass vars to loop
$per_page = $posts_per_page;
$columns = $post_columns; $columns = $post_columns;
$related = $_product->get_related(); $related = $_product->get_related();
@ -518,7 +524,7 @@ if (!function_exists('woocommerce_related_products')) {
$args = array( $args = array(
'post_type' => 'product', 'post_type' => 'product',
'ignore_sticky_posts' => 1, 'ignore_sticky_posts' => 1,
'posts_per_page' => $per_page, 'posts_per_page' => $posts_per_page,
'orderby' => $orderby, 'orderby' => $orderby,
'post__in' => $related 'post__in' => $related
); );

View File

@ -128,6 +128,8 @@ if (!function_exists('woocommerce_front_page_archive')) {
$paged = 1; $paged = 1;
} }
add_filter( 'parse_query', 'woocommerce_parse_query' );
query_posts( array( 'page_id' => '', 'post_type' => 'product', 'paged' => $paged ) ); query_posts( array( 'page_id' => '', 'post_type' => 'product', 'paged' => $paged ) );
define('SHOP_IS_ON_FRONT', true); define('SHOP_IS_ON_FRONT', true);