{function stock_editor_form stock=null substocks=null}
{strip}{if !empty($stock.id)} {if $substocks !== null} {$input_var = 'vedit'} {else} {$input_var = 'edit'} {/if} {$disabled = ' disabled="disabled"'} {else} {if $substocks !== null} {$input_var = 'vadd'} {else} {$input_var = 'add'} {/if} {$disabled = ''} {/if}{/strip}
[`Name`]
{if $substocks === null && empty($stock.id) && count($stocks) < 1}
{/if}
[`Indicator`]
[`Low`]
[`Critical`]
{if $substocks !== null}
[`Stocks and priority`]
{foreach array_keys(array_flip($substocks) + $stocks) as $sid}{if !empty($stocks[$sid]) && empty($stocks[$sid].substocks)} {$s = $stocks[$sid]}
{/if}{/foreach}

{sprintf('[`Virtual stock is a group of real stocks. The order of real stocks defines the priority for product stock update when order is placed. This is handy for grouping real stocks and points of sale which are located within the same geographical region, and defining rules for automated product stock updates. Help `]', '[`https://www.shop-script.com/help/12062/stocks/`]')}

{/if}
{/function}

[`Stocks`]

[`Inventory tracking is performed by stocks (warehouses) listed below. Yellow and red indicators are used to visually display low and critical stock levels in both backend and storefront.`]

{foreach $stocks as $stock} {/foreach} {capture "new_stock"}{strip} {/strip}{/capture} {capture "new_virtualstock"}{strip} {/strip}{/capture}

{$stock.name|escape} {if !$stock.public}{/if}

{$stock.low_count} ≤ {$stock.critical_count} [`Edit`] [`Delete`]
{stock_editor_form} [`Delete`]
{stock_editor_form substocks=[]} [`Delete`]
[`Update stock`]

[`Product stock levels will be updated (reduced) when this action is performed to the order.`]
[`With option “Not updated by order actions”, products’ stock level is supposed to be updated only during data exchange with accounting software, which is used to manage product stock updates.`]

[`Ordering`]
{* * Stock rules form *} {* * Helper to draw condition editor for rules *} {function rule_condition_editor_form conditions=null} {if $conditions} {foreach $conditions as $rule} {str_replace(['%%RULE_ID%%', '%%RULE_TYPE%%', '%%RULE_DATA%%'], [ $rule.id, $rule.rule_type, $rule.rule_data ], $smarty.capture.new_condition)} {/foreach} {/if} {/function} {* * HTML for new rule condition (before plugins have chance to alter its form) *} {capture "new_condition"}
{/capture} {* Helper to draw rulegroup rows *} {function rulegroup group=null} {if $group} {rule_condition_editor_form conditions=$group.conditions} {else} {rule_condition_editor_form} {/if} {* *} {/function} {$_show_rules = false} {if !empty($rule_groups) || (!empty($stocks) && $stocks|count > 1)} {$_show_rules = true} {/if}

[`Stock linking rules`]

[`When order is placed, ordered items will be automatically linked with a stock according to the rules defined below. E.g. different stocks may be preferred depending on selected shipping option or particular customer location. When no matching stock rule were found, ordered items will be linked to the current storefront default stock.`]

[`Add rule`]
{foreach $rule_groups as $group} {rulegroup group=$group} {/foreach} {capture "new_rule"}{strip} {rulegroup} {/strip}{/capture} {foreach $storefront_rule_groups as $row} {/foreach}
[`Condition`] [`Stock`]
[`Storefront`] {waIdna::dec($row.storefront)|escape} {$row.stock_name|escape}


{* * dialogs section *}

[`Delete stock`]

[`All products available on this stock will be saved on the balance of corresponding SKUs.`]
{$wa->csrf()} [`or`] [`cancel`]

[`Delete stock`]

{$wa->csrf()} [`or`] [`cancel`]