コード例 #1
0
ファイル: Markup.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Adds markup condition to the query builder object
  *
  * @param \Doctrine\ORM\QueryBuilder           $qb       Query builder object
  * @param \XLite\Logic\Order\Modifier\Shipping $modifier Shipping order modifier
  * @param integer                              $zoneId   Zone Id
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function addMarkupCondition(\Doctrine\ORM\QueryBuilder $qb, \XLite\Logic\Order\Modifier\Shipping $modifier, $zoneId)
 {
     $prepareSum = array('m.markup_flat', '(m.markup_percent * :value / 100)', '(m.markup_per_item * :items)', '(m.markup_per_weight * :weight)');
     $qb->addSelect(implode(' + ', $prepareSum) . ' as markup_value')->linkInner('m.zone')->andWhere('zone.zone_id = :zoneId')->setParameter('zoneId', $zoneId)->setParameter('weight', $modifier->getWeight())->setParameter('items', $modifier->countItems())->setParameter('value', $modifier->getSubtotal());
     $qb->linkInner('m.shipping_method');
     $qb->andWhere($qb->expr()->orX($qb->expr()->andX('shipping_method.tableType = :WSIType', 'm.min_weight <= :weightCondition', 'm.max_weight >= :weightCondition', 'm.min_total <= :totalCondition', 'm.max_total >= :totalCondition', 'm.min_items <= :itemsCondition', 'm.max_items >= :itemsCondition'), $qb->expr()->andX('shipping_method.tableType = :WType', 'm.min_weight <= :weightCondition', 'm.max_weight >= :weightCondition'), $qb->expr()->andX('shipping_method.tableType = :SType', 'm.min_total <= :totalCondition', 'm.max_total >= :totalCondition'), $qb->expr()->andX('shipping_method.tableType = :IType', 'm.min_items <= :itemsCondition', 'm.max_items >= :itemsCondition')));
     $qb->setParameter('totalCondition', $modifier->getSubtotalCondition())->setParameter('weightCondition', $modifier->getWeightCondition())->setParameter('itemsCondition', $modifier->countItemsCondition())->setParameter('WSIType', 'WSI')->setParameter('WType', 'W')->setParameter('SType', 'S')->setParameter('IType', 'I');
     return $qb;
 }
コード例 #2
0
ファイル: Markup.php プロジェクト: kingsj/core
 /**
  * Adds markup condition to the query builder object
  *
  * @param \Doctrine\ORM\QueryBuilder           $qb       Query builder object
  * @param \XLite\Logic\Order\Modifier\Shipping $modifier Shipping order modifier
  * @param integer                              $zoneId   Zone Id
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function addMarkupCondition(\Doctrine\ORM\QueryBuilder $qb, \XLite\Logic\Order\Modifier\Shipping $modifier, $zoneId)
 {
     $prepareSum = array('m.markup_flat', '(m.markup_percent * :value / 100)', '(m.markup_per_item * :items)', '(m.markup_per_weight * :weight)');
     return $qb->addSelect(implode(' + ', $prepareSum) . ' as markup_value')->innerJoin('m.zone', 'zone')->andWhere('m.min_weight <= :weight')->andWhere('zone.zone_id = :zoneId')->andWhere('m.max_weight >= :weight')->andWhere('m.min_total <= :total')->andWhere('m.max_total >= :total')->andWhere('m.min_items <= :items')->andWhere('m.max_items >= :items')->setParameters(array_merge($qb->getParameters(), array('zoneId' => $zoneId, 'weight' => $modifier->getWeight(), 'total' => $modifier->getSubtotal(), 'items' => $modifier->countItems(), 'value' => $modifier->getSubtotal())));
 }