Stripe Tax Banner | Q4 2024

added by Colleen Harrison - Partner Marketing

Product Icon

WooCommerce

by Woo
Sell online with the flexible, customizable eCommerce platform designed to grow with your business. From your first sale to millions in revenue, Woo is with you. See why merchants trust us to power 3.4 million online stores.

Add new function – option for Free Gift for Woocommerce

Hello Woo team,

Recently, I reached out to WooCommerce support and the developer of the Free Gift for WooCommerce plugin regarding an issue and a feature suggestion. The essence of my inquiry revolves around the plugin’s inability to detect hidden products within the WooCommerce product list and their respective categories. Specifically, private products hidden from the storefront are also not recognized by the plugin due to the absence of functionality in your `rule.php` file. This file lacks logic for handling private products.

For over a year, I’ve been using a custom modification of the `rule.php` function to manually detect these products. I alter the original `rule.php` function because the plugin lacks any hooks or options to specifically identify private products. These private products are intended as surprise items, not readily visible to users unless offered as gifts. Unfortunately, the current plugin does not support working with private products.

As a workaround, I’ve implemented my own logic, shown here:

“`php
/**
* Get the non-purchasable product.
*
* @return false/array
*/
public function get_non_purchasable_product( $product_ids ) {

if (!fgf_check_is_array($product_ids)) {
return false;
}

$non_purchasable_statuses = array(‘private’, ‘publish’);
$non_purchasable_products = array();

foreach ($product_ids as $product_id) {
$product = wc_get_product($product_id);

if (!is_object($product) || (in_array($product->get_status(), $non_purchasable_statuses) && $product->is_purchasable() && $product->is_in_stock())) {
continue;
}

$non_purchasable_products[] = ” . $product->get_name() . ”;
}

if (!fgf_check_is_array($non_purchasable_products)) {
return false;
}

return implode(‘, ‘, $non_purchasable_products);
}
“`

However, with each update, I must modify this function to ensure my private products can be included as gifts. It would greatly benefit the plugin’s functionality if you could add an option to handle private products in future updates. Thank you.

Free Gifts for WooCommerce

Author

manager13526b481c2

Current Status

Open

Last updated: July 7, 2024

0 comments

Log in to comment on this feature request.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.