Inheritance: implements LukePOLO\LaraCart\Contracts\LaraCartContract
Example #1
0
 /**
  * Gets the formatted price
  *
  * @param bool|true $format
  *
  * @return string
  */
 public function price($format = true)
 {
     $price = $this->price;
     if (isset($this->items)) {
         foreach ($this->items as $item) {
             $price += $item->price(false);
         }
     }
     return LaraCart::formatMoney($price, $this->locale, $this->internationalFormat, $format);
 }
Example #2
0
 /**
  * Gets the formatted price.
  *
  * @param bool|true $format
  * @param bool      $taxedItemsOnly
  *
  * @return string
  */
 public function price($format = true, $taxedItemsOnly = true)
 {
     $price = $this->price;
     if (isset($this->items)) {
         foreach ($this->items as $item) {
             if ($taxedItemsOnly && !$item->taxable) {
                 continue;
             }
             $price += $item->price(false, $taxedItemsOnly);
         }
     }
     return LaraCart::formatMoney($price, $this->locale, $this->internationalFormat, $format);
 }
Example #3
0
 /**
  * Gets the discount of an item
  *
  * @param boolean $format
  *
  * @return string
  */
 public function getDiscount($format = true)
 {
     $amount = 0;
     if (app('laracart')->findCoupon($this->code)) {
         $amount = $this->discount;
     }
     return LaraCart::formatMoney($amount, $this->locale, $this->internationalFormat, $format);
 }
Example #4
0
 /**
  * Gets the formatted amount
  *
  * @return string
  */
 public function getAmount()
 {
     return LaraCart::formatMoney($this->amount, $this->locale, $this->internationalFormat);
 }
Example #5
0
 /**
  * Gets the discount amount.
  *
  * @param $throwErrors boolean this allows us to capture errors in our code if we wish,
  * that way we can spit out why the coupon has failed
  *
  * @return string
  */
 public function discount($throwErrors = false)
 {
     return LaraCart::formatMoney(app(LaraCart::SERVICE)->subTotal(false) * $this->value, null, null, false);
 }
Example #6
0
 /**
  * Displays the value in a money format.
  *
  * @param null $locale
  * @param null $internationalFormat
  *
  * @return string
  */
 public function displayValue($locale = null, $internationalFormat = null)
 {
     return LaraCart::formatMoney($this->discount(), $locale, $internationalFormat);
 }
Example #7
0
 /**
  * Gets the totals for the options
  */
 public function subItemsTotal($tax = false, $format = true)
 {
     $total = 0;
     foreach ($this->subItems as $item) {
         if (isset($item->price)) {
             $total += array_get($item->options, 'price');
         }
     }
     if ($tax) {
         $total = $total + $total * $this->tax;
     }
     if ($format) {
         return \LaraCart::formatMoney($total, $this->locale, $this->internationalFormat);
     } else {
         return $total;
     }
 }
Example #8
0
 /**
  * Gets the total amount discounted
  *
  * @return int
  */
 public function getTotalDiscount($formatted = true)
 {
     $total = 0;
     foreach ($this->coupons as $coupon) {
         $total += $coupon->discount($this);
     }
     if ($formatted) {
         return \LaraCart::formatMoney($total, $this->locale, $this->internationalFormat);
     } else {
         return $total;
     }
 }