Order Status Available For Vendor

Can we somehow restrict the vendor accounts to be only able to set the order status to a specific set of Order Status only. e.g. Shipped / Cancelled

Rest of the Order Status can only be done by the Admin group members.

Unfortunately, it is not possible without additional code modifications

You should be able add an orders.post.php controller that will modify the order statuses if $runtime.company_id is not zero so the only displayed values will be those that you want the vendor to be able to change to.

Code modification is required.

You should be able add an orders.post.php controller that will modify the order statuses if $runtime.company_id is not zero so the only displayed values will be those that you want the vendor to be able to change to.

Hi tbirn,

I figured out there is already a hook for the same in details.tpl

Please guide me which var will be changed for this since I want the Vendors should be only able to mark the Order either Shipped (S) or Cancelled ( C )

{hook name="orders:order_status"}
                            {if $order_info.status == $smarty.const.STATUS_INCOMPLETED_ORDER}
                                {assign var="get_additional_statuses" value=true}
                            {else}
                                {assign var="get_additional_statuses" value=false}
                            {/if}
                            {assign var="order_status_descr" value=$smarty.const.STATUSES_ORDER|fn_get_simple_statuses:$get_additional_statuses:true}
                            {assign var="extra_status" value=$config.current_url|escape:"url"}
                            {if "MULTIVENDOR"|fn_allowed_for}
                                {assign var="notify_vendor" value=true}
                            {else}
                                {assign var="notify_vendor" value=false}
                            {/if}
                        {$statuses = []}
                        {assign var="order_statuses" value=$smarty.const.STATUSES_ORDER|fn_get_statuses:$statuses:$get_additional_statuses:true}
                        {include file="common/select_popup.tpl" suffix="o" id=$order_info.order_id status=$order_info.status items_status=$order_status_descr update_controller="orders" notify=true notify_department=true notify_vendor=$notify_vendor status_target_id="content_downloads" extra="&return_url=`$extra_status`" statuses=$order_statuses popup_additional_class="dropleft"}
                    {/hook}

You can either change the line of:

{$statuses = []}
or make an override hook and copy what’s enclosed in the hook to the file and then change that line to be:

{if “MULTIVENDOR”|fn_allowed_for && $runtime.company_id}
{$status = [‘S’, ‘C’]}
{elseif !$runtime.company_id}
{$status = []}
{/if}
I would probably do it as an override to prevent making distributed code modifications.
Note that above is UNTESTED.

Didnot work out. Its strange that still all the values are listed in popup both from admin and vendor account. Is there some place else which affects this code ? I did an override in order_status.override.tpl file in my_changes / hooks / orders

Should work, it would need debugging. Happy to do this on the clock for you, but consulting is my business. I'm happy to help where I can, but I can only go so far on forums.

I'm assuming you cleared your cache after making the changes.

There is a mistake in the code. Try this one:


{if “MULTIVENDOR”|fn_allowed_for && $runtime.company_id}
{$statuses = [‘S’, ‘C’]}
{elseif !$runtime.company_id}
{$statuses = []}
{/if}

There is a mistake in the code. Try this one:

{if "MULTIVENDOR"|fn_allowed_for && $runtime.company_id}
  {$statuses = ['S', 'C']}
{elseif !$runtime.company_id}
  {$statuses = []}
{/if}

Hi Ecom ,

I had already fixed that but the problem I am facing is in the file common/select_popup.tpl which uses this value for creating the order status. This variable $statuses is not used for creating the order status popup. See code below:

            {if $items_status}
            {foreach from=$items_status item="val" key="st"}
	
           
            
  • {$val}
  • {/foreach} {/if}

    Here the status of orders in popup are created using a variable called $items_status whose values are filled using $order_status_descr

    {assign var=“order_status_descr” value=$smarty.const.STATUSES_ORDER|fn_get_simple_statuses:$get_additional_statuses:true}
    .
    .
    .
    {assign var=“order_statuses” value=$smarty.const.STATUSES_ORDER|fn_get_statuses:$statuses:$get_additional_statuses:true}

    {include file=“common/select_popup.tpl” suffix=“o” id=$order_info.order_id status=$order_info.status items_status=$order_status_descr update_controller=“orders” notify=true notify_department=true notify_vendor=$notify_vendor status_target_id=“content_downloads” extra=“&return_url=$extra_status” statuses=$order_statuses popup_additional_class=“dropleft”}

    So I donot want to touch the common code. It seems that we need to change the $items_status field to show only the selected Order Status in popup to Vendors. Correct me if my analysis is incorrect. And Thanks once again for helping out.

    OK. I see, in this case you should change the $order_status_descr variable. For example,

    {assign var="order_status_descr" value=$smarty.const.STATUSES_ORDER|fn_get_simple_statuses:$get_additional_statuses:true}
    {if "MULTIVENDOR"|fn_allowed_for && $runtime.company_id}
      {$order_status_descr = $order_status_descr|fn_correct_vendor_statuses}
    {/if}

    Then add new php function:

    function fn_correct_vendor_statuses($statuses)
    {
        foreach ($statuses as $k => $v) {
            if (!in_array($v['status'], array('S', 'C'))) {
                unset($statuses[$k]);
            }
        }
        return $statuses;
    }

    (!) Not tested

    Thanks ecom it works with some modifications. :-)

    Be sure to post your final (working) solution for others.

    function fn_vendor_status_allowed($statuses,$selected)
    {
        $allowed = array('I', 'E'); // I = Cancelled , E = Shipped
    
        array_push($allowed,$selected);
        foreach ($statuses as $k => $v) {
            if (!in_array($k,$allowed )) {
                unset($statuses[$k]);
            }
        }
        return $statuses;
    }
    

    Above is the final code.

    fleaffair, thank you

    function fn_vendor_status_allowed($statuses,$selected)
    {
    $allowed = array(‘I’, ‘E’); // I = Cancelled , E = Shipped

    array_push($allowed,$selected);
    foreach ($statuses as $k => $v) {
        if (!in_array($k,$allowed )) {
            unset($statuses[$k]);
        }
    }
    return $statuses;
    

    }

    Above is the final code.

    Where exactly did you place this code?

    thanks!

    in app/addons/my_changes/func.php

    There is an add-on for this http://marketplace.cs-cart.com/add-ons/site-management/vendor-restrictions.html