shipping costs

This commit is contained in:
Kevin Adametz 2019-01-07 00:15:41 +01:00
parent d4f6a774d0
commit 22a2b4710a
20 changed files with 797 additions and 457 deletions

View file

@ -105,6 +105,7 @@ class Product extends Model
'price_ek',
'tax',
'price_old',
'weight',
'contents',
'number',
'icons',

View file

@ -30,7 +30,7 @@ class Shipping extends Model
}
public function getFormattedFree()
{
if($this->attributes['free'] === null) {
if($this->free === null) {
return "";
}
if(\App::getLocale() == "en"){

View file

@ -22,4 +22,5 @@ class ShippingCountry extends Model
{
return $this->belongsTo('App\Models\Country', 'country_id');
}
}

View file

@ -18,47 +18,75 @@ class ShippingPrice extends Model
}
public function _format_number($value){
public function _format_number($value)
{
return preg_replace("/[^0-9,]/", "", $value);
}
public function setPriceAttribute( $value ) {
public function setPriceAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['price'] = floatval(str_replace(',', '.', $value));
}
public function setFactorAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['factor'] = floatval(str_replace(',', '.', $value));
}
public function setTaxAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['tax'] = floatval(str_replace(',', '.', $value));
}
public function setPriceOldAttribute( $value ) {
$value = $this->_format_number($value);
$this->attributes['price_old'] = floatval(str_replace(',', '.', $value));
}
public function setTotalFromAttribute( $value ) {
public function setFactorAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['total_from'] = floatval(str_replace(',', '.', $value));
if ($value == "") {
$this->attributes['factor'] = null;
} else {
$this->attributes['factor'] = floatval(str_replace(',', '.', $value));
}
}
public function setTotalToAttribute( $value ) {
public function setTaxAttribute($value)
{
$value = $this->_format_number($value);
$this->attributes['total_to'] = floatval(str_replace(',', '.', $value));
if ($value == "") {
$this->attributes['tax'] = null;
} else {
$this->attributes['tax'] = floatval(str_replace(',', '.', $value));
}
}
public function setTotalFromAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['total_from'] = null;
} else {
$this->attributes['total_from'] = floatval(str_replace(',', '.', $value));
}
}
public function setTotalToAttribute($value)
{
$value = $this->_format_number($value);
if ($value == "") {
$this->attributes['total_to'] = null;
} else {
$this->attributes['total_to'] = floatval(str_replace(',', '.', $value));
}
}
public function getFormattedPrice()
{
if(\App::getLocale() == "en"){
if (\App::getLocale() == "en") {
return number_format($this->attributes['price'], 2, '.', ',');
}
return number_format($this->attributes['price'], 2, ',', '.');
}
public function getFormattedTax()
{
if(\App::getLocale() == "en"){
if ($this->attributes['tax'] === NULL) {
return $this->attributes['tax'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['tax'], 2, '.', ',');
}
return number_format($this->attributes['tax'], 2, ',', '.');
@ -66,7 +94,10 @@ class ShippingPrice extends Model
public function getFormattedFactor()
{
if(\App::getLocale() == "en"){
if ($this->attributes['factor'] === NULL) {
return $this->attributes['factor'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['factor'], 2, '.', ',');
}
return number_format($this->attributes['factor'], 2, ',', '.');
@ -75,19 +106,25 @@ class ShippingPrice extends Model
public function getFormatTotalFrom()
{
if(\App::getLocale() == "en"){
if ($this->attributes['total_from'] === NULL) {
return $this->attributes['total_from'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['total_from'], 2, '.', ',');
}
return number_format($this->attributes['total_from'], 2, ',', '.');
}
public function getFormattedTotalTo()
{
if(\App::getLocale() == "en"){
if ($this->attributes['total_to'] === NULL) {
return $this->attributes['total_to'];
}
if (\App::getLocale() == "en") {
return number_format($this->attributes['total_to'], 2, '.', ',');
}
return number_format($this->attributes['total_to'], 2, ',', '.');
}
}

View file

@ -47,6 +47,11 @@ class UserShop extends Model
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
}
public function getActiveDateFormatSmall(){
if(!$this->attributes['active_date']){ return ""; }
return Carbon::parse($this->attributes['active_date'])->format("d.m.Y");
}
public function getSubdomain()
{