/**
  * Process OrderState for Order
  *
  * @param CoreShopOrder $order
  * @param null $locale
  * @return bool
  * @throws \Exception
  */
 public function processStep(CoreShopOrder $order, $locale = null)
 {
     $emailDocument = $this->getEmailDocument($locale);
     $emailParameters = array("order" => $order, "newOrderStatus" => $this, "user" => $order->getCustomer());
     if ($this->getAccepted()) {
     }
     if ($this->getShipped()) {
     }
     if ($this->getPaid()) {
         Plugin::actionHook("paymentConfirmation", array("order" => $order));
     }
     Plugin::actionHook("orderStatusUpdate", array("newOrderStatus" => $this, "order" => $order));
     if ($this->getEmail() && $emailDocument instanceof Document\Email) {
         $mail = new Mail();
         $mail->setDocument($emailDocument);
         $mail->setParams($emailParameters);
         $mail->addTo($order->getCustomer()->getEmail(), $order->getCustomer()->getFirstname() . " " . $order->getCustomer()->getLastname());
         Tool::addAdminToMail($mail);
         $mail->send();
     }
     $order->setOrderState($this);
     $order->save();
     return true;
     //TODO: Stock Management
 }
 public function preDispatch()
 {
     parent::preDispatch();
     $result = Plugin::getEventManager()->trigger('action.' . $this->getRequest()->getActionName(), $this, array("controller" => $this, "request" => $this->getRequest()), function ($v) {
         return is_array($v) && array_key_exists("action", $v) && array_key_exists("controller", $v) && array_key_exists("module", $v);
     });
     if ($result->stopped()) {
         $forward = $result->last();
         $this->_forward($forward['action'], $forward['controller'], $forward['module'], $forward['params']);
     }
 }
 protected function paymentSuccess(CoreShopPayment $payment)
 {
     $paymentSuccessHandled = false;
     $result = \CoreShop\Plugin::getEventManager()->trigger('payment.success', $this, array("payment" => $payment, "language" => $this->language), function ($v) {
         return is_bool($v);
     });
     if ($result->stopped()) {
         $paymentSuccessHandled = $result->last();
     }
     if (!$paymentSuccessHandled) {
         $order = $payment->getOrder();
         if ($order instanceof CoreShopOrder) {
             $stateAccepted = CoreShopOrderState::getByPath("/coreshop/order-states/01-order-accepted");
             //TODO: Make Order State per Type Configurable
             $stateAccepted->processStep($order);
             $statePaied = CoreShopOrderState::getByPath("/coreshop/order-states/02-payment-received");
             //TODO: Make Order State per Type Configurable
             $statePaied->processStep($order);
         }
     }
 }
 public function removeClassmap()
 {
     if (is_file(Plugin::getClassmapFile())) {
         unlink(Plugin::getClassmapFile());
     }
 }
        <!-- product Info Ends -->
            <?php 
if (strlen($this->product->getDescription()) > 0) {
    ?>
        <!-- Product Description Starts -->
            <div class="product-info-box">
                <h4 class="heading"><?php 
    echo $this->translate("Description");
    ?>
</h4>
                <div class="content panel-smart">
                    <?php 
    echo $this->product->getDescription();
    ?>
                </div>
            </div>
        <!-- Product Description Ends -->
            <?php 
}
?>

            <?php 
echo \CoreShop\Plugin::hook("product-detail-bottom", array("product" => $this->product));
?>
        
        
        </div>
    <!-- Primary Content Ends -->
    </div>
</div>
<!-- Main Container Ends -->
 public function attachEvents()
 {
     \CoreShop\Plugin::getEventManager()->attach("hook.product-detail-bottom", function ($e) {
         return $this;
     });
 }
 public function modifyAction()
 {
     $cartItem = $this->getParam("cartItem", null);
     $amount = $this->getParam("amount");
     $item = CoreShopCartItem::getById($cartItem);
     $isAllowed = true;
     $result = Plugin::getEventManager()->trigger('cart.preModify', $this, array("cartItem" => $item, "cart" => $this->cart, "request" => $this->getRequest()), function ($v) {
         return is_bool($v);
     });
     if ($result->stopped()) {
         $isAllowed = $result->last();
     }
     unset($this->session->order);
     if ($isAllowed) {
         if ($item instanceof CoreShopCartItem) {
             $this->cart->modifyItem($item, $amount);
             Plugin::getEventManager()->trigger('cart.postModify', $this, array("item" => $item, "cart" => $this->cart));
             $this->_helper->json(array("success" => true, "cart" => $this->cart->toArray()));
         }
     } else {
         $this->_helper->json(array("success" => false, "message" => 'not allowed'));
     }
     $this->_helper->json(array("success" => false, "cart" => $this->cart->toArray()));
 }
 public function attachEvents()
 {
     \CoreShop\Plugin::getEventManager()->attach("shipping.getProvider", function ($e) {
         return $this;
     });
 }
Beispiel #9
0
 /**
  * Uninstall Plugin
  */
 public static function uninstall()
 {
     if (class_exists("\\CoreShop\\Plugin")) {
         \CoreShop\Plugin::uninstallPlugin(self::getShop()->getInstall());
     }
 }
Beispiel #10
0
<!-- Sidebar Starts -->
<div class="col-md-3">
    <?php 
echo \CoreShop\Plugin::hook("product-left-column");
?>

    <?php 
echo $this->template("coreshop/helper/left/categories.php");
?>

<?php 
/*
<!-- Special Products Starts -->
   <h3 class="side-heading">Specials</h3>
   <ul class="side-products-list">
   <!-- Special Product #1 Starts -->
       <li class="clearfix">
           <img src="/static/images/product-images/spl-product-img1.jpg" alt="Special product" class="img-responsive" />
           <h5><a href="#">Olympus Digital Camera</a></h5>
           <div class="price">
               <span class="price-new">$199.50</span>
               <span class="price-old">$249.50</span>
           </div>
       </li>
   <!-- Special Product #1 Ends -->
   <!-- Special Product #2 Starts -->
       <li class="clearfix">
           <img src="/static/images/product-images/spl-product-img2.jpg" alt="Special product" class="img-responsive" />
           <h5><a href="#">Olympus Digital Camera</a></h5>
           <div class="price">
               <span class="price-new">$599.50</span>
 public function registerAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getAllParams();
         $addressParams = array();
         $userParams = array();
         foreach ($params as $key => $value) {
             if (startsWith($key, "address_")) {
                 $addressKey = str_replace("address_", "", $key);
                 $addressParams[$addressKey] = $value;
             } else {
                 $userParams[$key] = $value;
             }
         }
         try {
             //Check User exists
             if (CoreShopUser::getUniqueByEmail($userParams['email']) instanceof CoreShopUser) {
                 throw new \Exception("E-Mail already exists");
             }
             $folder = "/users/" . strtolower(substr($userParams['lastname'], 0, 1));
             $adresses = new Object\Fieldcollection();
             $address = new CoreShopUserAddress();
             $address->setValues($addressParams);
             $address->setCountry(Country::getById($addressParams['country']));
             $adresses->add($address);
             $user = new CoreShopUser();
             $user->setKey(Pimcore\File::getValidFilename($userParams['email']));
             $user->setPublished(true);
             $user->setParent(Pimcore\Model\Object\Service::createFolderByPath($folder));
             $user->setValues($userParams);
             $user->setAddresses($adresses);
             $user->save();
             Plugin::getEventManager()->trigger('user.postAdd', $this, array("request" => $this->getRequest(), "user" => $user));
             $this->session->user = $user;
             if (array_key_exists("_redirect", $params)) {
                 $this->_redirect($params['_redirect']);
             }
         } catch (\Exception $ex) {
             $this->view->error = $ex->getMessage();
         }
     }
 }
 public function paymentAction()
 {
     $this->checkIsAllowed();
     $this->view->provider = Plugin::getPaymentProviders($this->cart);
     if ($this->getRequest()->isPost()) {
         $paymentProvider = reset($this->getParam("payment_provider", array()));
         foreach ($this->view->provider as $provider) {
             if ($provider->getIdentifier() == ${$paymentProvider}) {
                 $paymentProvider = $provider;
                 break;
             }
         }
         if (!$provider instanceof Payment) {
             $this->view->error = "oh shit, not found";
         } else {
             $this->session->order['paymentProvider'] = $provider;
             $order = new CoreShopOrder();
             $order->setKey(uniqid());
             $order->setParent(Service::createFolderByPath('/coreshop/orders/' . date('Y/m/d')));
             $order->setPublished(true);
             $order->setLang($this->view->language);
             $order->setCustomer($this->session->user);
             $order->setShippingAddress($this->session->order['address']['delivery']);
             $order->setBillingAddress($this->session->order['address']['billing']);
             $order->setPaymentProvider($provider->getIdentifier());
             $order->setOrderDate(new \Zend_Date());
             if ($this->session->order['shippingProvider'] instanceof Shipping) {
                 $order->setShippingProvider($this->session->order['shippingProvider']->getIdentifier());
                 $order->setShipping($this->session->order['shippingProvider']->getShipping($this->cart));
             } else {
                 $order->setShipping(0);
             }
             $order->save();
             $order->importCart($this->cart);
             $this->session->orderId = $order->getId();
             $this->_helper->viewRenderer($provider->processPayment($order, $this->view->url(array("action" => "paymentreturn"), "coreshop_checkout")), null, true);
         }
     }
     $this->view->headTitle($this->view->translate("Payment"));
 }
 /**
  * calculates shipping costs for the cart
  *
  * @return int
  */
 public function getShipping()
 {
     $session = Tool::getSession();
     //check for existing shipping
     if (array_key_exists("shippingProvider", $session->order) && $session->order['deliveryProvider'] instanceof Shipping) {
         return $session->order['shippingProvider']->getShipping($this);
     }
     //get all provider and choose cheapest
     $providers = Plugin::getShippingProviders($this);
     $cheapestProvider = null;
     foreach ($providers as $p) {
         if ($cheapestProvider === null) {
             $cheapestProvider = $p;
         } else {
             if ($cheapestProvider->getShipping($this) > $p->getShipping($this)) {
                 $cheapestProvider = $p;
             }
         }
     }
     if ($cheapestProvider instanceof Shipping) {
         return $cheapestProvider->getShipping($this);
     }
     return 0;
 }