Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions includes/Extensions/FluentCart/FluentCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,31 @@ public function nx_can_entry($return, $entry, $settings){
$status_matches = true;
}

// Return the original return value if status matches, otherwise return false
return $status_matches ? $return : false;
if (!$status_matches) {
return false;
}

// Apply the product / category filter (Show Purchase Of / Exclude Products).
// Real-time orders bypass get_orders(), so this filter is the only place
// these settings are enforced for live FluentCart orders.
$product_id = !empty($entry['data']['product_id']) ? (int) $entry['data']['product_id'] : 0;
if ($product_id) {
$order_item = (object) ['post_id' => $product_id];

$categories = [];
$product_categories = get_the_terms($product_id, 'product-categories');
if (!is_wp_error($product_categories) && !empty($product_categories)) {
$categories = $product_categories;
}

// Mirrors the condition used inside get_orders(): when _excludes_product
// and _show_purchaseof agree, the item should NOT pass the filter.
if ($this->_excludes_product($order_item, $settings, $categories) === $this->_show_purchaseof($order_item, $settings, $categories)) {
return false;
}
}

return $return;
}

public function product_lists($products) {
Expand Down
Loading