Hi,
That's what we do here:
www.hikashop.com/support/documentation/5...ashop-changelog.html
However, we only do that for releases. Not for nightly builds, because we publish nightly builds almost every day. If we were to publish a new version of HikaShop every day, it would bother everyone having to update their HikaShop all the time for nothing.
This issue with the required check not being done properly only occurs when you don't set any product or category restriction in the custom field. So you can always select your main category in the category restriction of the custom field and it will work properly.
Otherwise the patch is to replace the code:
if($field->field_table == 'order' && ($field->field_products != 'all' || $field->field_categories != 'all')){
$cartClass = hikashop_get('class.cart');
$cart = $cartClass->loadFullCart(true);
$inCart = false;
$restricted_products = array ();
$restricted_categories = array();
//Product check
if($field->field_products != 'all'){
$restricted_products = explode(',', $field->field_products);
$restricted_products = array_filter($restricted_products);
if (!isset($cart->cart_products) && isset($cart->products)) {
$cart->cart_products = $cart->products;
}
foreach($cart->cart_products as $cart_product){
if(in_array($cart_product->product_id, $restricted_products))
$inCart = true;
}
}
//Category check
if($field->field_categories != 'all' && !$inCart){
$restricted_categories = explode(',', $field->field_categories);
$restricted_categories = array_filter($restricted_categories);
$fieldClass = hikashop_get('class.field');
$cart_categories = $fieldClass->getCategories('order', $cart);
foreach($restricted_categories as $restricted_category){
if($field->field_with_sub_categories && in_array($restricted_category, $cart_categories['parents']))
$inCart = true;
else if(!$field->field_with_sub_categories && in_array($restricted_category, $cart_categories['originals']))
$inCart = true;
}
}
by:
if($field->field_table == 'order' && (!in_array($field->field_products, array('all', '')) || !in_array($field->field_categories, array('all', '')))){
$cartClass = hikashop_get('class.cart');
$cart = $cartClass->loadFullCart(true);
$inCart = false;
$restricted_products = array ();
$restricted_categories = array();
//Product check
if(!in_array($field->field_products, array('all', ''))){
$restricted_products = explode(',', $field->field_products);
$restricted_products = array_filter($restricted_products);
if (!isset($cart->cart_products) && isset($cart->products)) {
$cart->cart_products = $cart->products;
}
foreach($cart->cart_products as $cart_product){
if(in_array($cart_product->product_id, $restricted_products))
$inCart = true;
}
}
//Category check
if(!in_array($field->field_categories, array('all', '')) && !$inCart){
$restricted_categories = explode(',', $field->field_categories);
$restricted_categories = array_filter($restricted_categories);
$fieldClass = hikashop_get('class.field');
$cart_categories = $fieldClass->getCategories('order', $cart);
foreach($restricted_categories as $restricted_category){
if($field->field_with_sub_categories && in_array($restricted_category, $cart_categories['parents']))
$inCart = true;
else if(!$field->field_with_sub_categories && in_array($restricted_category, $cart_categories['originals']))
$inCart = true;
}
}
in the file administrator/components/com_hikashop/classes/field.php