- Posts: 1184
- Thank you received: 13
Notification if someone change quantity
3 years 6 months ago #350213
by verzevoul
Notification if someone change quantity was created by verzevoul
Hello!
Is there a way to restrict the quantity edit on certain usergroups?
Or notify via email the admin if somenone saves a product with changed number in the field quantity?
Is there a way to restrict the quantity edit on certain usergroups?
Or notify via email the admin if somenone saves a product with changed number in the field quantity?
Please Log in or Create an account to join the conversation.
3 years 6 months ago #350217
by nicolas
Replied by nicolas on topic Notification if someone change quantity
Hi,
While there is no ready-made solution, there are two things I can propose:
- This plugin integrates with Joomla's logging system:
www.hikashop.com/marketplace/product/161-action-log.html
With it, you can log who modified the products when.
- You could create a mass action with a trigger "before a product is updated" and an action "run PHP code".
In the action, you can write a bit of PHP to:
1. check if the quantity is being changed
2. check the user group of the current user
3. stop the process with an error message
For example, something like that (not tested):
where XXX and YYY are the user groups allowed to change the quantity. You might also want to add a check on whether you're on the backend or not, as some processes on the frontend might change the quantity while you might not want to trigger your mass action at that time.
While there is no ready-made solution, there are two things I can propose:
- This plugin integrates with Joomla's logging system:
www.hikashop.com/marketplace/product/161-action-log.html
With it, you can log who modified the products when.
- You could create a mass action with a trigger "before a product is updated" and an action "run PHP code".
In the action, you can write a bit of PHP to:
1. check if the quantity is being changed
2. check the user group of the current user
3. stop the process with an error message
For example, something like that (not tested):
Code:
$new_qty = (int)'{product_quantity}';
$db = JFactory::getDBO();
$db->setQuery('SELECT product_quantity FROM #__hikashop_product WHERE product_id = {product_id}');
$old_qty = $db->loadResult();
if($new_qty != $old_qty) {
if(!hikashop_isAllowed('XXX,YYY')) {
die('you are not allowed to change the quantity');
}
}
The following user(s) said Thank You: verzevoul
Please Log in or Create an account to join the conversation.
3 years 6 months ago #350408
by verzevoul
Replied by verzevoul on topic Notification if someone change quantity
Hello!
Can we add on the script you send me 2 more checks?
Prevent unpublish of products and delete?
Can we add on the script you send me 2 more checks?
Prevent unpublish of products and delete?
Please Log in or Create an account to join the conversation.
3 years 6 months ago #350414
by nicolas
Replied by nicolas on topic Notification if someone change quantity
Hi,
This would require new mass actions to be created with different code.
For the unpublish, it's quite easy. You would basically just change "product_quantity" to "product_published" in the code.
For the delete, you would just have the "before a product is deleted" trigger, and the code would simplify to just:
This would require new mass actions to be created with different code.
For the unpublish, it's quite easy. You would basically just change "product_quantity" to "product_published" in the code.
For the delete, you would just have the "before a product is deleted" trigger, and the code would simplify to just:
Code:
if(!hikashop_isAllowed('XXX,YYY')) {
die('you are not allowed to change the quantity');
}
Please Log in or Create an account to join the conversation.
Time to create page: 0.130 seconds