Esempio n. 1
0
 /**
  * @param $plugin
  *
  * @throws ShopgateLibraryException
  */
 public function __construct($plugin)
 {
     parent::__construct($plugin);
     /** @var CartCore $cart */
     $cart = new Cart();
     $cart->id_lang = $this->getPlugin()->getLanguageId();
     $cart->id_currency = $this->getPlugin()->getContext()->currency->id;
     $cart->recyclable = 0;
     $cart->gift = 0;
     $this->getPlugin()->getContext()->cart = $cart;
     /**
      * check / create shopgate carrier
      */
     /** @var CarrierCore $sgCarrier */
     $sgCarrier = new Carrier(Configuration::get('SG_CARRIER_ID'));
     if (!$sgCarrier->id) {
         $shopgateShippingModel = new ShopgateShipping(new ShopGate());
         $shopgateShippingModel->createShopgateCarrier();
     }
     /**
      * check all needed table columns
      */
     $shopGate = new ShopGate();
     if (!$shopGate->updateTables()) {
         throw new ShopgateLibraryException(ShopgateLibraryException::PLUGIN_DATABASE_ERROR, sprintf('Cannot update shopgate_order_table'));
     }
 }
/**
 * @param ShopGate $module
 *
 * @return bool
 */
function upgrade_module_2_9_52($module)
{
    $shopgateCarrierId = Configuration::get('SG_CARRIER_ID');
    /**
     * set current shopgate carrier as deleted
     */
    if ($shopgateCarrierId) {
        /** @var CarrierCore $carrier */
        $carrier = new Carrier($shopgateCarrierId);
        $carrier->deleted = true;
        $carrier->save();
    }
    $shopgateShippingModel = new ShopgateShipping($module);
    $shopgateShippingModel->createShopgateCarrier();
    $module->updateTables();
    return true;
}