php - How to edit user permissions only for selected fields on Opencart?

238

I've set up a non-admin user group on OC dashboard. Now I need to give permission for that user group to view and update all products but not to update Model and Quantity (only to view model and quantity). How could I do this?

75

Answer

Solution:

It can't be done by default in OpenCart, you will need to look for an answer on the forums: https://forum.opencart.com/viewtopic.php?t=134562

Or in the extension store: https://www.opencart.com/index.php?route=marketplace/extension&filter_search=permissions

764

Answer

Solution:

Finally this is how I solved:

Added the following lines to admin/controller/catalog/product.php

$this->load->model('user/user_group');
$data['user_groups_id'] = $this->user->getGroupId();

Then updated admin/view/template/catalog/product_form.twig

{% if user_groups_id == 11 %}
  <input type="text" name="sku" value="{{ sku }}" placeholder="{{ entry_sku }}" 
   id="input-sku" disabled/>
{% else %}
  <input type="text" name="sku" value="{{ sku }}" placeholder="{{ entry_sku }}" 
   id="input-sku" />
{% endif %}

People are also looking for solutions to the problem: PHP require_once fails but require works

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.