コード例 #1
0
 /**
  * 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
 }
コード例 #2
0
 protected function prepareCart()
 {
     $this->cart = $this->view->cart = Tool::prepareCart();
     if ($this->session->user instanceof CoreShopUser && !$this->cart->getUser() instanceof CoreShopUser) {
         $this->cart->setUser($this->session->user);
         $this->cart->save();
     }
     PriceRule::autoRemoveFromCart($this->cart);
     PriceRule::autoAddToCart($this->cart);
 }
コード例 #3
0
 /**
  * Check if Cart is Valid for Condition
  *
  * @param Cart $cart
  * @param PriceRule $priceRule
  * @param bool|false $throwException
  * @return bool
  * @throws \Exception
  */
 public function checkCondition(Cart $cart, PriceRule $priceRule, $throwException = false)
 {
     if ($this->getCountry()->getId() !== Tool::getCountry()->getId()) {
         if ($throwException) {
             throw new \Exception("You cannot use this voucher in your country of delivery");
         } else {
             return false;
         }
     }
     return true;
 }
コード例 #4
0
 /**
  * Check if Cart is Valid for Condition
  *
  * @param Cart $cart
  * @param PriceRule $priceRule
  * @param bool|false $throwException
  * @return bool
  * @throws \Exception
  */
 public function checkCondition(Cart $cart, PriceRule $priceRule, $throwException = false)
 {
     $session = Tool::getSession();
     if ($cart->getUser() instanceof CoreShopUser && $session->user instanceof CoreShopUser) {
         if (!$cart->getUser()->getId() == $session->user->getId()) {
             if ($throwException) {
                 throw new \Exception("You cannot use this voucher");
             } else {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #5
0
 /**
  * Check if Cart is Valid for Condition
  *
  * @param Cart $cart
  * @param PriceRule $priceRule
  * @param bool|false $throwException
  * @return bool
  * @throws \Exception
  */
 public function checkCondition(Cart $cart, PriceRule $priceRule, $throwException = false)
 {
     //Check Cart Amount
     if ($this->getMinAmount() > 0) {
         $minAmount = $this->getMinAmount();
         $minAmount = Tool::convertToCurrency($minAmount, $this->getCurrency(), Tool::getCurrency());
         $cartTotal = $cart->getSubtotal();
         if ($minAmount > $cartTotal) {
             if ($throwException) {
                 throw new \Exception("You have not reached the minimum amount required to use this voucher");
             } else {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #6
0
 /**
  * Converts value from currency to currency
  *
  * @param $value
  * @param Currency|null $toCurrency
  * @param Currency|null $fromCurrency
  * @return mixed
  */
 public static function convertToCurrency($value, Currency $toCurrency = null, Currency $fromCurrency = null)
 {
     $config = Config::getConfig();
     $configArray = $config->toArray();
     if (!$fromCurrency instanceof Currency) {
         $fromCurrency = Currency::getById($configArray['base']['base-currency']);
     }
     if (!$toCurrency instanceof Currency) {
         $toCurrency = Tool::getCurrency();
     }
     if ($fromCurrency instanceof Currency) {
         if ($toCurrency instanceof Currency && $toCurrency->getId() != $fromCurrency->getId()) {
             return $value * $toCurrency->getExchangeRate();
         }
     }
     return $value;
 }
コード例 #7
0
 public function paymentAction()
 {
     $configkey = \CoreShop\Model\Configuration::get('SOFORTUEBERWEISUNG.KEY');
     $sofort = new \Sofort\SofortLib\Sofortueberweisung($configkey);
     $sofort->setAmount(Tool::numberFormat($this->cart->getTotal()));
     $sofort->setVersion('CoreShop ' . \CoreShop\Version::getVersion());
     $sofort->setReason('Buy Order (CoreShop)');
     $sofort->setCurrencyCode(Tool::getCurrency()->getIsoCode());
     $sofort->setSuccessUrl(Pimcore\Tool::getHostUrl() . $this->getModule()->url($this->getModule()->getIdentifier(), 'payment-return'));
     $sofort->setAbortUrl(Pimcore\Tool::getHostUrl() . $this->getModule()->url($this->getModule()->getIdentifier(), 'payment-return-abort'));
     $sofort->sendRequest();
     if ($sofort->isError()) {
         var_dump($sofort);
         die('error');
     } else {
         $transactionId = $sofort->getTransactionId();
         $this->cart->setCustomIdentifier($transactionId);
         $this->cart->save();
         $this->redirect($sofort->getPaymentUrl());
     }
 }
コード例 #8
0
 /**
  * Check if Cart is Valid for Condition
  *
  * @param Cart $cart
  * @param PriceRule $priceRule
  * @param bool|false $throwException
  * @return bool
  * @throws \Exception
  */
 public function checkCondition(Cart $cart, PriceRule $priceRule, $throwException = false)
 {
     $session = Tool::getSession();
     //Check Total For Customer
     if ($session->user instanceof CoreShopUser) {
         $orders = $session->user->getOrders();
         $cartRulesUsed = 0;
         foreach ($orders as $order) {
             if ($order->getPriceRule() instanceof PriceRule && $order->getPriceRule()->getId() == $priceRule->getId()) {
                 $cartRulesUsed++;
             }
         }
         if ($cartRulesUsed >= $this->getTotal()) {
             if ($throwException) {
                 throw new \Exception("You cannot use this voucher anymore (usage limit reached)");
             } else {
                 return false;
             }
         }
     }
     return true;
 }
コード例 #9
0
 /**
  * Returns the CartItem as array
  *
  * @return array+
  */
 public function toArray()
 {
     return array("id" => $this->getId(), "product" => $this->getProduct()->toArray(), "amount" => $this->getAmount(), "price" => Tool::formatPrice($this->product->getProductPrice()), "total" => Tool::formatPrice($this->getTotal()));
 }
コード例 #10
0
if ($shipping > 0) {
    ?>
        <tr>
            <td>   </td>
            <td>   </td>
            <td><?php 
    echo $this->translate("Versandkosten");
    ?>
</td>
            <td class="text-right"><strong><?php 
    echo \CoreShop\Tool::formatPrice($shipping);
    ?>
</strong></td>
        </tr>
    <?php 
}
?>
    <tr>
        <td>   </td>
        <td>   </td>
        <td><?php 
echo $this->translate("Gesamt");
?>
</td>
        <td class="text-right"><strong class="cart-total-price"><?php 
echo \CoreShop\Tool::formatPrice($this->order->getTotal());
?>
</strong></td>
    </tr>
    </tbody>
</table>
コード例 #11
0
    ?>
                            </td>
                            <td class="payment-option-text">
                                <strong><?php 
    echo $provider->getName();
    ?>
</strong> <?php 
    echo $provider->getDescription();
    ?>
                            </td>
                            <?php 
    $paymentFee = $provider->getPaymentFee($this->cart);
    if ($paymentFee > 0) {
        ?>
                                    <td class="payment-option-price"><?php 
        echo \CoreShop\Tool::formatPrice($paymentFee);
        ?>
</td>
                                    <?php 
    }
    ?>

                        </tr>

                    </table>

                <?php 
}
?>

コード例 #12
0
 /**
  * Returns the cart as array
  *
  * @return array
  */
 public function toArray()
 {
     $items = array();
     foreach ($this->getItems() as $item) {
         $items[] = $item->toArray();
     }
     return array("user" => $this->getUser() ? $this->getUser()->toArray() : null, "items" => $items, "subtotal" => Tool::formatPrice($this->getSubtotal()), "total" => Tool::formatPrice($this->getTotal()));
 }
コード例 #13
0
                    <td class="text-right"><strong><?php 
echo $this->translate("Subtotal");
?>
</strong></td>
                    <td class="text-left cart-subtotal"><?php 
echo \CoreShop\Tool::formatPrice($this->cart->getSubtotal());
?>
</td>
                </tr>
                <tr>
                    <td class="text-right"><strong><?php 
echo $this->translate("Total");
?>
</strong></td>
                    <td class="text-left cart-total"><?php 
echo \CoreShop\Tool::formatPrice($this->cart->getTotal());
?>
</td>
                </tr>
                </tbody>
            </table>
            <p class="text-right btn-block1">
                <a href="<?php 
echo $this->url(array("lang" => $this->language, "action" => "list"), "coreshop_cart");
?>
">
                    <?php 
echo $this->translate("View Cart");
?>
                </a>
                <a href="<?php 
コード例 #14
0
">
                                <?php 
    }
    ?>
                            </td>
                            <td class="delivery-option-text">
                                <strong><?php 
    echo $provider->getName();
    ?>
</strong> <?php 
    echo $provider->getDescription();
    ?>
                            </td>
                            <td class="delivery-option-price">
                                <?php 
    echo \CoreShop\Tool::formatPrice($provider->getShipping($this->cart));
    ?>
                            </td>
                        </tr>

                    </table>

                <?php 
}
?>

                <div class="row">
                    <div class="col-xs-12">
                        <a href="<?php 
echo $this->url(array("lang" => $this->language, "action" => "address"), "coreshop_checkout");
?>
コード例 #15
0
 /**
  * Calculate discount
  *
  * @param CoreShopCart $cart
  * @return int
  */
 public function getDiscount(CoreShopCart $cart)
 {
     $discount = Tool::convertToCurrency($this->getGift()->getProductPrice(), Tool::getCurrency());
     return $discount;
 }
コード例 #16
0
 /**
  * Get Discount for PriceRule
  *
  * @return int
  */
 public function getDiscount()
 {
     $cart = Tool::prepareCart();
     $discount = 0;
     foreach ($this->getActions() as $action) {
         $discount += $action->getDiscount($cart);
     }
     return $discount;
 }
コード例 #17
0
?>
"><?php 
echo $this->product->getName();
?>
</a></h4>
            <div class="description">
                <?php 
echo $this->product->getShortDescription();
?>
            </div>
            <?php 
if ($this->product->getAvailableForOrder()) {
    ?>
                <div class="price">
                    <span class="price-new"><?php 
    echo \CoreShop\Tool::formatPrice($this->product->getProductPrice());
    ?>
</span>
                    <!--<span class="price-old">$249.50</span>-->
                </div>
                <div class="cart-button button-group">
                    <button type="button" title="Wishlist" class="btn btn-wishlist">
                        <i class="fa fa-heart"></i>
                    </button>
                    <button type="button" title="Compare" class="btn btn-compare">
                        <i class="fa fa-bar-chart-o"></i>
                    </button>
                    <button type="button" class="btn btn-cart" data-id="<?php 
    echo $this->product->getId();
    ?>
" data-img="#product-image-<?php 
コード例 #18
0
 /**
  * Calculate discount
  *
  * @param Model\Object\CoreShopCart $cart
  * @return int
  */
 public function getDiscount(Model\Object\CoreShopCart $cart)
 {
     return Tool::convertToCurrency($this->getAmount(), $this->getCurrency(), Tool::getCurrency());
 }
コード例 #19
0
 public function toArray()
 {
     return Tool::objectToArray($this);
 }
コード例 #20
0
 /**
  * Calculate Product Price
  *
  * @depcreated: Should be replaced with PriceRules
  *
  * @return float|mixed
  * @throws \Exception
  */
 public function getProductPrice()
 {
     $cacheKey = "coreshop_product_price_" . $this->getId();
     if ($price = \Pimcore\Model\Cache::load($cacheKey)) {
         return $price;
     }
     $price = $this->getPrice();
     if (count($this->getSpecificPrice()) > 0) {
         $session = Tool::getSession();
         //Process Specific Prices
         foreach ($this->getSpecificPrice() as $sPrice) {
             $date = \Zend_Date::now();
             $hasCustomer = false;
             $hasCountry = false;
             $hasCurrency = false;
             if ($sPrice->getFrom() instanceof \Zend_Date) {
                 if ($date->get(\Zend_Date::TIMESTAMP) < $sPrice->getFrom()->get(\Zend_Date::TIMESTAMP)) {
                     continue;
                 }
             }
             if ($sPrice->getTo() instanceof \Zend_Date) {
                 if ($date->get(\Zend_Date::TIMESTAMP) > $sPrice->getTo()->get(\Zend_Date::TIMESTAMP)) {
                     continue;
                 }
             }
             if (count($sPrice->getCustomers()) > 0 && $session->user instanceof CoreShopUser) {
                 foreach ($sPrice->getCustomers() as $cust) {
                     if ($cust->getId() == $session->user->getId()) {
                         $hasCustomer = true;
                     }
                 }
             } else {
                 if (count($sPrice->getCustomers()) == 0) {
                     //Non is selected means all Users
                     $hasCustomer = true;
                 }
             }
             if (count($sPrice->getCountries()) > 0 && Tool::objectInList(Tool::getCountry(), $sPrice->getCountries())) {
                 $hasCountry = true;
             } else {
                 if (count($sPrice->getCountries()) == 0) {
                     //Non selected means all
                     $hasCountry = true;
                 }
             }
             if (count($sPrice->getCurrencies()) > 0 && Tool::objectInList(Tool::getCurrency(), $sPrice->getCurrencies())) {
                 $hasCurrency = true;
             } else {
                 if (count($sPrice->getCountries()) == 0) {
                     //Non selected means all
                     $hasCurrency = true;
                 }
             }
             if ($hasCountry && $hasCustomer && $hasCurrency) {
                 $price = $this->applySpecificPrice($sPrice);
                 break;
             }
         }
     }
     return Tool::convertToCurrency($price);
 }