1С (CommerceML) Call to undefined method shopHelper::getOrderShippingInterval Есть решение

Перестала работать синхронизация заказов с мойсклад (https://online.moysklad.ru ( до этого год работало, на сайте ничего за последнее время не менялось)

плагин передаёт XML файл вот с такой записью

<br />

<b>Fatal error</b>: Call to undefined method shopHelper::getOrderShippingInterval() in<b>/home/h21785/data/www/owo.com.ua/wa-apps/shop/plugins/cml1c/lib/actions/backend/shopCml1cPluginBackendRun.controller.php</b>on line <b>3186</b><br />


вот упомянутая строка 3186 в файле shopCml1cPluginBackendRun.controller.php :

list($date, $time_start, $time_end) = shopHelper::getOrderShippingInterval($params);


менял время синхронизации как на стороне моегосклада так и в плагине, переустанавливал плагин - не помогло. На данном хостинге работает другой мой аналогичный сайт, но с другим товаром, там настроено всё один в один на 100% - и там всё работает, а тут нет :(


подскажите в чём может быть проблема?


2 ответа

  • 1
    Сергей Салов 16 марта 2018 10:37 # Решение

    спасибо за быстрый ответ, вставил данный код. Ошибка в строке 3186 уже не упоминается, но стала упоминаться ошибка в строке 3197

    вот упомянутая строка 3197 в файле shopCml1cPluginBackendRun.controller.php :

    $item['currency'] = $order['currency'];


    но вы натолкнули меня на мысль, я заменил файл wa-apps/shop/lib/classes/shopHelper.class.phpс рабочего сайта на своём нерабочем и всё - заработало. Не принесет ли этот способ другие ошибки и подводные камни, которых сейчас не видно?

    Вот код данного файла (рабочего)

    <span class="pun"><?</span><span class="pln">php
    
    </span><span class="kwd">class</span><span class="pln"> shopHelper
    </span><span class="pun">{</span><span class="pln">
        </span><span class="com">/**
         * Returns HTML code of a Webasyst icon.
         *
         * @param string|null $icon Icon type
         * @param string|null $default Default icon type to be used if $icon is empty.
         * @param int $size Icon size in pixels. Available sizes: 10, 16.
         * @param array $params Extra parameters:
         *     'class' => class name tp be added to icon's HTML code
         * @return string
         */</span><span class="pln">
        </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getIcon</span><span class="pun">(</span><span class="pln">$icon</span><span class="pun">,</span><span class="pln"> $default </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln"> $size </span><span class="pun">=</span><span class="pln"> </span><span class="lit">16</span><span class="pun">,</span><span class="pln"> $params </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">())</span><span class="pln">
        </span><span class="pun">{</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">$icon </span><span class="pun">&&</span><span class="pln"> $default</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                $icon </span><span class="pun">=</span><span class="pln"> $default</span><span class="pun">;</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            $class </span><span class="pun">=</span><span class="pln"> isset</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="str">'class'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="str">' '</span><span class="pun">.</span><span class="pln">htmlentities</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="str">'class'</span><span class="pun">],</span><span class="pln"> ENT_QUOTES</span><span class="pun">,</span><span class="pln"> </span><span class="str">'utf-8'</span><span class="pun">)</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="str">''</span><span class="pun">;</span><span class="pln">
    
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$icon</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">preg_match</span><span class="pun">(</span><span class="str">'/^icon\.([\d\w_\-]+)$/'</span><span class="pun">,</span><span class="pln"> $icon</span><span class="pun">,</span><span class="pln"> $matches</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    $size </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$size </span><span class="pun">==</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="lit">16</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="lit">10</span><span class="pun">;</span><span class="pln">
                    $icon </span><span class="pun">=</span><span class="pln"> </span><span class="str">"<i class='icon{$size} {$matches[1]}{$class}'></i>"</span><span class="pun">;</span><span class="pln">
                </span><span class="pun">}</span><span class="pln"> elseif </span><span class="pun">(</span><span class="pln">preg_match</span><span class="pun">(</span><span class="str">'@[\\/]+@'</span><span class="pun">,</span><span class="pln"> $icon</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    $size </span><span class="pun">=</span><span class="pln"> max</span><span class="pun">(</span><span class="lit">10</span><span class="pun">,</span><span class="pln"> min</span><span class="pun">(</span><span class="lit">16</span><span class="pun">,</span><span class="pln"> $size</span><span class="pun">));</span><span class="pln">
                    $icon </span><span class="pun">=</span><span class="pln"> </span><span class="str">"<i class='icon{$size} {$class}' style='background: url({$icon})'></i>"</span><span class="pun">;</span><span class="pln">
                </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    $size </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$size </span><span class="pun">==</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> </span><span class="lit">16</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="lit">10</span><span class="pun">;</span><span class="pln">
                    $icon </span><span class="pun">=</span><span class="pln"> </span><span class="str">"<i class='icon{$size} {$icon}{$class}'></i>"</span><span class="pun">;</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> $icon</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    
        </span><span class="com">/**
         * Returns array of payment methods.
         *
         * @param array $order Array of order data whose parameters must be pre-filled in payment method's custom fields.
         * @return array
         */</span><span class="pln">
        </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getPaymentMethods</span><span class="pun">(</span><span class="pln">$order </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">())</span><span class="pln">
        </span><span class="pun">{</span><span class="pln">
            $plugin_model </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> shopPluginModel</span><span class="pun">();</span><span class="pln">
            $methods </span><span class="pun">=</span><span class="pln"> $plugin_model</span><span class="pun">-></span><span class="pln">listPlugins</span><span class="pun">(</span><span class="pln">shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">);</span><span class="pln">
            $order_params </span><span class="pun">=</span><span class="pln"> $order </span><span class="pun">?</span><span class="pln"> $order</span><span class="pun">[</span><span class="str">'params'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
            $order </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> waOrder</span><span class="pun">(</span><span class="pln">
                array</span><span class="pun">(</span><span class="pln">
                    </span><span class="str">'contact_id'</span><span class="pln"> </span><span class="pun">=></span><span class="pln"> $order </span><span class="pun">?</span><span class="pln"> $order</span><span class="pun">[</span><span class="str">'contact_id'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln">
                    </span><span class="str">'contact'</span><span class="pln">    </span><span class="pun">=></span><span class="pln"> $order </span><span class="pun">?</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> waContact</span><span class="pun">(</span><span class="pln">$order</span><span class="pun">[</span><span class="str">'contact_id'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln">
                    </span><span class="str">'params'</span><span class="pln">     </span><span class="pun">=></span><span class="pln"> $order_params</span><span class="pun">,</span><span class="pln">
                </span><span class="pun">)</span><span class="pln">
            </span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$methods </span><span class="kwd">as</span><span class="pln"> $m_id </span><span class="pun">=></span><span class="pln"> $m</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                $plugin </span><span class="pun">=</span><span class="pln"> shopPayment</span><span class="pun">::</span><span class="pln">getPlugin</span><span class="pun">(</span><span class="pln">$m</span><span class="pun">[</span><span class="str">'plugin'</span><span class="pun">],</span><span class="pln"> $m</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">]);</span><span class="pln">
                $custom_fields </span><span class="pun">=</span><span class="pln"> $plugin</span><span class="pun">-></span><span class="pln">customFields</span><span class="pun">(</span><span class="pln">$order</span><span class="pun">);</span><span class="pln">
                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$custom_fields</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    $params </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
                    $params</span><span class="pun">[</span><span class="str">'namespace'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">'payment_'</span><span class="pun">.</span><span class="pln">$m</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span><span class="pln">
                    $params</span><span class="pun">[</span><span class="str">'title_wrapper'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">'%s'</span><span class="pun">;</span><span class="pln">
                    $params</span><span class="pun">[</span><span class="str">'description_wrapper'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<br><span class="hint">%s</span>'</span><span class="pun">;</span><span class="pln">
                    $params</span><span class="pun">[</span><span class="str">'control_wrapper'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<div class="name">%s</div><div class="value">%s %s</div>'</span><span class="pun">;</span><span class="pln">
                    $params</span><span class="pun">[</span><span class="str">'control_separator'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="str">'</div><div class="value>"'</span><span class="pun">;</span><span class="pln">
    
                    $controls </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
                    </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$custom_fields </span><span class="kwd">as</span><span class="pln"> $name </span><span class="pun">=></span><span class="pln"> $row</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                        $row </span><span class="pun">=</span><span class="pln"> array_merge</span><span class="pun">(</span><span class="pln">$row</span><span class="pun">,</span><span class="pln"> $params</span><span class="pun">);</span><span class="pln">
                        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$order_params</span><span class="pun">[</span><span class="str">'payment_id'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$m</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> $order_params</span><span class="pun">[</span><span class="str">'payment_id'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">&&</span><span class="pln"> isset</span><span class="pun">(</span><span class="pln">$order_params</span><span class="pun">[</span><span class="str">'payment_params_'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">]))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            $row</span><span class="pun">[</span><span class="str">'value'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> $order_params</span><span class="pun">[</span><span class="str">'payment_params_'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">];</span><span class="pln">
                        </span><span class="pun">}</span><span class="pln">
                        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$row</span><span class="pun">[</span><span class="str">'control_type'</span><span class="pun">]))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            $controls</span><span class="pun">[</span><span class="pln">$name</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> waHtmlControl</span><span class="pun">::</span><span class="pln">getControl</span><span class="pun">(</span><span class="pln">$row</span><span class="pun">[</span><span class="str">'control_type'</span><span class="pun">],</span><span class="pln"> $name</span><span class="pun">,</span><span class="pln"> $row</span><span class="pun">);</span><span class="pln">
                        </span><span class="pun">}</span><span class="pln">
                    </span><span class="pun">}</span><span class="pln">
                    </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$controls</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                        $custom_html </span><span class="pun">=</span><span class="pln"> </span><span class="str">''</span><span class="pun">;</span><span class="pln">
                        </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$controls </span><span class="kwd">as</span><span class="pln"> $c</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            $custom_html </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<div class="field">'</span><span class="pun">.</span><span class="pln">$c</span><span class="pun">.</span><span class="str">'</div>'</span><span class="pun">;</span><span class="pln">
                        </span><span class="pun">}</span><span class="pln">
                        $methods</span><span class="pun">[</span><span class="pln">$m_id</span><span class="pun">][</span><span class="str">'custom_html'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> $custom_html</span><span class="pun">;</span><span class="pln">
                    </span><span class="pun">}</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> $methods</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    
        </span><span class="com">/**
         * Returns unavailable payment methods for specified shipping method or shipping methods for which specified payment method is unavailable.
         *
         * @param string $type Method type for which other type will be considered as complimentary; acceptable values: 'payment' or 'shipping'
         * @param int $id Id of method for which methods of other type must be returned
         * @return array Method ids
         */</span><span class="pln">
        </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getDisabledMethods</span><span class="pun">(</span><span class="pln">$type</span><span class="pun">,</span><span class="pln"> $id</span><span class="pun">)</span><span class="pln">
        </span><span class="pun">{</span><span class="pln">
            $map </span><span class="pun">=</span><span class="pln"> wa</span><span class="pun">()-></span><span class="pln">getSetting</span><span class="pun">(</span><span class="str">'shipping_payment_disabled'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln"> </span><span class="str">'shop'</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">$map</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                </span><span class="kwd">return</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            $result </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
            $map </span><span class="pun">=</span><span class="pln"> json_decode</span><span class="pun">(</span><span class="pln">$map</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">is_array</span><span class="pun">(</span><span class="pln">$map</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                $complementary </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$type </span><span class="pun">==</span><span class="pln"> shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">)</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_SHIPPING </span><span class="pun">:</span><span class="pln"> shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">;</span><span class="pln">
                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$complementary </span><span class="pun">==</span><span class="pln"> shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    $result </span><span class="pun">=</span><span class="pln"> isset</span><span class="pun">(</span><span class="pln">$map</span><span class="pun">[</span><span class="pln">$id</span><span class="pun">])</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> $map</span><span class="pun">[</span><span class="pln">$id</span><span class="pun">]</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
                </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$map </span><span class="kwd">as</span><span class="pln"> $plugin_id </span><span class="pun">=></span><span class="pln"> $values</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">in_array</span><span class="pun">(</span><span class="pln">$id</span><span class="pun">,</span><span class="pln"> $values</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            $result</span><span class="pun">[]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> $plugin_id</span><span class="pun">;</span><span class="pln">
                        </span><span class="pun">}</span><span class="pln">
                    </span><span class="pun">}</span><span class="pln">
                </span><span class="pun">}</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            </span><span class="kwd">return</span><span class="pln"> $result</span><span class="pun">;</span><span class="pln">
        </span><span class="pun">}</span><span class="pln">
    
        </span><span class="com">/**
         * Returns available shipping methods and rates for specified address.
         *
         * @param array $address Address data
         * @param array $items Order items
         * @param array $params Optional extra parameters:
         *     'payment'     => [int] payment method id for which available shipping methods must be returned
         *     'currency'    => [string] currency code to convert shipping rates to
         *     'total_price' => [float] arbitrary total order items cost to be taken into account for obtaining shipping rates
         *     'no_external' => [bool]
         *     'allow_external_for' => int[] array of external shipping methods' ids
         * @return array
         */</span><span class="pln">
        </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> getShippingMethods</span><span class="pun">(</span><span class="pln">$address </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">,</span><span class="pln"> $items </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">(),</span><span class="pln"> $params </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">())</span><span class="pln">
        </span><span class="pun">{</span><span class="pln">
            $plugin_model </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> shopPluginModel</span><span class="pun">();</span><span class="pln">
            $options </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="pln">shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">]))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                $options</span><span class="pun">[</span><span class="pln">shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> $params</span><span class="pun">[</span><span class="pln">shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_PAYMENT</span><span class="pun">];</span><span class="pln">
            </span><span class="pun">}</span><span class="pln">
            $methods </span><span class="pun">=</span><span class="pln"> $plugin_model</span><span class="pun">-></span><span class="pln">listPlugins</span><span class="pun">(</span><span class="pln">shopPluginModel</span><span class="pun">::</span><span class="pln">TYPE_SHIPPING</span><span class="pun">,</span><span class="pln"> $options</span><span class="pun">);</span><span class="pln">
            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$address </span><span class="pun">!==</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                $config </span><span class="pun">=</span><span class="pln"> wa</span><span class="pun">(</span><span class="str">'shop'</span><span class="pun">)-></span><span class="pln">getConfig</span><span class="pun">();</span><span class="pln">
                </span><span class="com">/** @var $config shopConfig */</span><span class="pln">
                $result </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">();</span><span class="pln">
                $currency </span><span class="pun">=</span><span class="pln"> isset</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="str">'currency'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> $params</span><span class="pun">[</span><span class="str">'currency'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> $config</span><span class="pun">-></span><span class="pln">getCurrency</span><span class="pun">();</span><span class="pln">
                $params</span><span class="pun">[</span><span class="str">'allow_external_for'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">array</span><span class="pun">)</span><span class="pln">ifempty</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="str">'allow_external_for'</span><span class="pun">],</span><span class="pln"> array</span><span class="pun">());</span><span class="pln">
                $dimensions </span><span class="pun">=</span><span class="pln"> shopDimension</span><span class="pun">::</span><span class="pln">getInstance</span><span class="pun">();</span><span class="pln">
    
                </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$methods </span><span class="kwd">as</span><span class="pln"> $m</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                    </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$m</span><span class="pun">[</span><span class="str">'available'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                        $method_id </span><span class="pun">=</span><span class="pln"> $m</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span><span class="pln">
                        $plugin </span><span class="pun">=</span><span class="pln"> shopShipping</span><span class="pun">::</span><span class="pln">getPlugin</span><span class="pun">(</span><span class="pln">$m</span><span class="pun">[</span><span class="str">'plugin'</span><span class="pun">],</span><span class="pln"> $method_id</span><span class="pun">);</span><span class="pln">
                        $plugin_info </span><span class="pun">=</span><span class="pln"> $plugin</span><span class="pun">-></span><span class="pln">info</span><span class="pun">(</span><span class="pln">$m</span><span class="pun">[</span><span class="str">'plugin'</span><span class="pun">]);</span><span class="pln">
                        $plugin_currency </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">array</span><span class="pun">)</span><span class="pln">$plugin</span><span class="pun">-></span><span class="pln">allowedCurrency</span><span class="pun">();</span><span class="pln">
    
                        $total </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">
                        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$plugin_currency </span><span class="pun">!=</span><span class="pln"> $currency</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">$config</span><span class="pun">-></span><span class="pln">getCurrencies</span><span class="pun">(</span><span class="pln">$plugin_currency</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                                $result</span><span class="pun">[</span><span class="pln">$method_id</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> array</span><span class="pun">(</span><span class="pln">
                                    </span><span class="str">'plugin'</span><span class="pln">   </span><span class="pun">=></span><span class="pln"> $m</span><span class="pun">[</span><span class="str">'plugin'</span><span class="pun">],</span><span class="pln">
                                    </span><span class="str">'logo'</span><span class="pln">     </span><span class="pun">=></span><span class="pln"> $m</span><span class="pun">[</span><span class="str">'logo'</span><span class="pun">],</span><span class="pln">
                                    </span><span class="str">'icon'</span><span class="pln">     </span><span class="pun">=></span><span class="pln"> $plugin_info</span><span class="pun">[</span><span class="str">'icon'</span><span class="pun">],</span><span class="pln">
                                    </span><span class="str">'img'</span><span class="pln">      </span><span class="pun">=></span><span class="pln"> $plugin_info</span><span class="pun">[</span><span class="str">'img'</span><span class="pun">],</span><span class="pln">
                                    </span><span class="str">'name'</span><span class="pln">     </span><span class="pun">=></span><span class="pln"> $m</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">],</span><span class="pln">
                                    </span><span class="str">'error'</span><span class="pln">    </span><span class="pun">=></span><span class="pln"> sprintf</span><span class="pun">(</span><span class="pln">
                                        _w</span><span class="pun">(</span><span class="str">'Shipping rate was not calculated because required currency %s is not defined in your store settings.'</span><span class="pun">),</span><span class="pln">
                                        implode</span><span class="pun">(</span><span class="str">', '</span><span class="pun">,</span><span class="pln"> $plugin_currency</span><span class="pun">)</span><span class="pln">
                                    </span><span class="pun">),</span><span class="pln">
                                    </span><span class="str">'rate'</span><span class="pln">     </span><span class="pun">=></span><span class="pln"> </span><span class="str">''</span><span class="pun">,</span><span class="pln">
                                    </span><span class="str">'currency'</span><span class="pln"> </span><span class="pun">=></span><span class="pln"> $currency</span><span class="pun">,</span><span class="pln">
                                    </span><span class="str">'external'</span><span class="pln"> </span><span class="pun">=></span><span class="pln"> </span><span class="pun">!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$plugin_info</span><span class="pun">[</span><span class="str">'external'</span><span class="pun">]),</span><span class="pln">
                                </span><span class="pun">);</span><span class="pln">
                                </span><span class="kwd">continue</span><span class="pun">;</span><span class="pln">
                            </span><span class="pun">}</span><span class="pln">
                        </span><span class="pun">}</span><span class="pln">
                        </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">isset</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="str">'total_price'</span><span class="pun">]))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">in_array</span><span class="pun">(</span><span class="pln">$currency</span><span class="pun">,</span><span class="pln"> $plugin_currency</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                                $total </span><span class="pun">=</span><span class="pln"> shop_currency</span><span class="pun">(</span><span class="pln">$params</span><span class="pun">[</span><span class="str">'total_price'</span><span class="pun">],</span><span class="pln"> $currency</span><span class="pun">,</span><span class="pln"> reset</span><span class="pun">(</span><span class="pln">$plugin_currency</span><span class="pun">),</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
                            </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                                $total </span><span class="pun">=</span><span class="pln"> $params</span><span class="pun">[</span><span class="str">'total_price'</span><span class="pun">];</span><span class="pln">
                            </span><span class="pun">}</span><span class="pln">
                        </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                            </span><span class="kwd">foreach</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$items </span><span class="kwd">as</span><span class="pln"> $item</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$item</span><span class="pun">[</span><span class="str">'price'</span><span class="pun">]))</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
                                    $total </span><span class="pun">+=</span><span class="pln"> $item</span><span class="pun">[</span><span class="str">'price'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> </span><span class="pun">(</span><span class="pln">isset</span><span class="pun">(</span><span class="pln">$item</span><span class="pun">[</span><span class="str">'quantity'</span><span class="pun">])</span><span class="pln"> </span><span class="pun">?</span><span class="pln"> $item</span><span class="pun">[</span><span class="str">'quantity'</span><span class="pun">]</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pun">);</span><span class="pln">
                                </span><span class="pun">}</span><span class="pln">
                                </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">$total </span><span class="pun">&&</span><span class="pln"> </span><span class="pun">!</span><span class="pln">in_array</span><span class="pun">(</span><span class="pln">$currency</span><span class="pun">,&
                
    • +2
      Михаил Ушенин Михаил Ушенин Webasyst 16 марта 2018 12:12 #

      Судя по тому, что у вас был неоригинальный файл, что-то не так в вашем магазине. Сразу дать точный без подробного изучения не получится.

      • +3
        Михаил Ушенин Михаил Ушенин Webasyst 16 марта 2018 12:41 #

        Кажется, у вас Shop-Script 6, а в нём нет функции, которую я упомянул. Разработчики планируют добавить проверку версии Shop-Script в плагин, чтобы для старой версии эта функция не вызывалась.

  • 2
    Михаил Ушенин Webasyst 16 марта 2018 09:32 #

    В файле wa-apps/shop/lib/classes/shopHelper.class.php у вас должен присутствовать вот такой фрагмент кода:

    public static function getOrderShippingInterval($order_params)
    {
        $shipping_date = null;
        $shipping_time_end = null;
        $shipping_time_start = null;
        if (!empty($order_params['shipping_start_datetime']) && !empty($order_params['shipping_end_datetime'])) {
            @list($shipping_date, $shipping_time_start) = explode(' ', $order_params['shipping_start_datetime'], 2);
            @list($_, $shipping_time_end) = explode(' ', $order_params['shipping_end_datetime'], 2);
            $shipping_time_start = preg_replace('~(\d\d:\d\d):\d\d~', '$1', $shipping_time_start);
            $shipping_time_end = preg_replace('~(\d\d:\d\d):\d\d~', '$1', $shipping_time_end);
        }
        return array($shipping_date, $shipping_time_start, $shipping_time_end);
    }

Добавить ответ

Чтобы добавить комментарий, зарегистрируйтесь или войдите