Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
Fix related products notice
Browse files Browse the repository at this point in the history
  • Loading branch information
megawebmaster committed Sep 12, 2014
1 parent 345d841 commit 118de44
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Fix: Paying for pending orders.
* Fix: Proper checkbox saving in admin panel.
* Fix: Adding variations JavaScripts.
* Fix: Notice when related products are enabled.
* Improved: `get_sku()` method on product variation object will now return variation SKU (if not available - product SKU).
* Improved: Added `number` option type.
* Improved: Replaced `range` items with `number` ones - better to use (visible values).
Expand Down
26 changes: 16 additions & 10 deletions classes/jigoshop_product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1066,21 +1066,27 @@ public function get_related( $limit = 5 ) {
),
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $cats
),
array(
'taxonomy' => 'product_tag',
'field' => 'id',
'terms' => $tags
),
),
);

if (!empty($cats)) {
$query['tax_query'][] = array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $cats
);
}
if (!empty($tags)) {
$query['tax_query'][] = array(
'taxonomy' => 'product_tag',
'field' => 'id',
'terms' => $tags
);
}

// Run the query
$q = get_posts( $query );

wp_reset_postdata();

return $q;
Expand Down
5 changes: 3 additions & 2 deletions jigoshop_template_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ function jigoshop_get_image_placeholder( $size = 'shop_small' ) {
**/
if (!function_exists('jigoshop_output_related_products')) {
function jigoshop_output_related_products() {
$jigoshop_options = Jigoshop_Base::get_options();
if ($jigoshop_options->get_option ('jigoshop_enable_related_products') != 'no')
$options = Jigoshop_Base::get_options();
if ($options->get_option ('jigoshop_enable_related_products') != 'no')
// 2 Related Products in 2 columns
jigoshop_related_products( 2, 2 );
}
Expand All @@ -836,6 +836,7 @@ function jigoshop_output_related_products() {
if (!function_exists('jigoshop_related_products')) {
function jigoshop_related_products( $posts_per_page = 4, $post_columns = 4, $orderby = 'rand' ) {

/** @var $_product jigoshop_product */
global $_product, $columns, $per_page;

// Pass vars to loop
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ However, if you want priority, dedicated support from Jigoshop staff, we dp offe
* Fix: Paying for pending orders.
* Fix: Proper checkbox saving in admin panel.
* Fix: Adding variations JavaScripts.
* Fix: Notice when related products are enabled.
* Improved: `get_sku()` method on product variation object will now return variation SKU (if not available - product SKU).
* Improved: Added `number` option type.
* Improved: Replaced `range` items with `number` ones - better to use (visible values).
Expand Down

0 comments on commit 118de44

Please sign in to comment.