Digital Downloads

I am looking for a way for vendors to be able to sell digital downloads in only one category.
So, I have created a category called “Digital Downloads” but I need to set it that any vendor that sells a digital product, will automatically put it into that category and will not be allowed elsewhere.

Hello!

You can use the update_product_pre hook in order to achieve such a behavior.

In example of the My changes addon, the function might look like this one:

use Tygh\Enum\YesNo;

function fn_my_changes_update_product_pre(array &$product_data, $product_id, $lang_code, $can_update)
{
    if (
         isset($product_data['is_edp'])
        && YesNo::toBool($product_data['is_edp'])
    ) {
        $product_data['category_ids'] = [123]; // 123 is the ID of your category for the digital products
    }
}

I hope it will help you.

1 Like