Skip to content

Instantly share code, notes, and snippets.

@SergeR
Created August 22, 2016 11:47
Show Gist options
  • Select an option

  • Save SergeR/46c5b9a7aa0113d8cb91afbc50181bd2 to your computer and use it in GitHub Desktop.

Select an option

Save SergeR/46c5b9a7aa0113d8cb91afbc50181bd2 to your computer and use it in GitHub Desktop.
{* Вставить в шаблон этапа выбора способа доставки, в самое начало, такой код: *}
{strip}
{$_user_region=null}
{$_shipping_addresses = $wa->user('address', null)}
{if !$_shipping_addresses}
{$_sess=$wa->session('shop/checkout')}
{if $_sess.contact && ($_sess['contact'] instanceof waContact)}
{$_shipping_addresses = $_sess.contact->get('address', null)}
{/if}
{/if}
{if $_shipping_addresses && is_array($_shipping_addresses)}
{foreach $_shipping_addresses as $_saddr}
{if $_saddr.ext == 'shipping'}
{if $_saddr.data.country == 'rus'}{$_user_region=$_saddr.data.region}{/if}
{break}
{/if}
{/foreach}
{/if}
{if $_user_region && $_user_region=='77'}{* Region 77 is a Moscow *}
{$_disabled_method_ids=[3,37]}{* Comma-separated list of delivery method IDs *}
{$_filtered_methods=[]}
{foreach $checkout_shipping_methods as $csm_id=>$csm}
{if !in_array($csm['id'],$_disabled_method_ids)}{$_filtered_methods[$csm_id]=$csm}{/if}
{/foreach}
{$checkout_shipping_methods = $_filtered_methods}
{/if}
{/strip}
{*
$_disabled_method_ids=[3,37] <-- это запрещенные методы для конкретного региона, через запятую. Посмотреть эти ID можно в настройках метода доставки, там url каждого метода заканчивается как-то так: /shipping/plugin/setup/48/ <-- вот 48 это и есть ID метода доставки
*}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment