The function Product idIsOnCategoryId in PHP takes two arguments; the first argument is a product ID, and the second argument is a category ID. It checks whether the product is assigned to a specific category.
Below is an example of the code using Product idIsOnCategoryId function in PHP:
function idIsOnCategoryId($product_id, $category_id) { $product_categories = get_categories($product_id); if (in_array($category_id, $product_categories)) { return true; } return false; }
$product_id = 123; // set the product ID $category_id = 456; // set the category ID $on_category = idIsOnCategoryId($product_id, $category_id); echo "Product $product_id is " . ($on_category ? "" : "not ") . "assigned to category $category_id";
In this example, the function uses the get_categories function to retrieve the categories that the product is assigned to. If the category ID is found in the list of categories assigned to the product, the function returns true. Otherwise, it returns false.
The package library for this function would likely be a custom library within a larger project, as it is a specific function designed to work within a particular system or application.
PHP Product::idIsOnCategoryId - 27 examples found. These are the top rated real world PHP examples of Product::idIsOnCategoryId from package yupe extracted from open source projects. You can rate examples to help us improve the quality of examples.