This commit is contained in:
Kevin Adametz 2020-07-01 13:21:35 +02:00
parent 9ed251820e
commit da08e9ff37
13 changed files with 378 additions and 56 deletions

View file

@ -56,13 +56,14 @@ class ShoppingUserController extends Controller
], 400);
}
$status = [];
//TODO Status
foreach ($wp_order_numbers as $wp_order_number){
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
$status[] = [
'wp_order_number' => $wp_order_number,
'user' => $shopping_user ? true : false,
'order' => ($shopping_user && $shopping_user->shopping_order) ? true : false,
'status' => 'open | sent | ...',
'status' => 'free',
];
}
return response()->json([
@ -109,13 +110,15 @@ class ShoppingUserController extends Controller
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
}
//TODO Status
$data[] = [
'wp_order_number' => $wp_order_number,
'user' => $user,
'order' => $order,
'customer_number' => $shopping_user ? $shopping_user->number : false,
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
'status' => 'open | sent | ...',
'status' => 'free',
];
}
return response()->json([
@ -195,7 +198,7 @@ class ShoppingUserController extends Controller
$priority = CustomerPriority::checkChangeOne($shopping_user, $data, true);
$updated = $shopping_user->fill($data)->save();
\App\Services\Shop::newUserOrder($shopping_user->number);
//TODO Status
if ($updated){
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
@ -208,7 +211,7 @@ class ShoppingUserController extends Controller
'customer_priority' => $priority,
'customer_number' => $shopping_user ? $shopping_user->number : false,
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
'status' => 'open | sent | ...',
'status' => 'free',
],
'time' => Carbon::now()->toDateTimeString()
], 200);
@ -249,6 +252,7 @@ class ShoppingUserController extends Controller
$wp_order = $request->wp_order;
}
$wp_order = $this->prepareOrder($wp_order, $shopping_user);
//TODO Status
if ($wp_order){
$user = $this->prepareForShow($shopping_user);
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
@ -261,6 +265,7 @@ class ShoppingUserController extends Controller
'order' => $order,
'customer_number' => $shopping_user->number,
'member_email' => $shopping_user->member->email,
'status' => 'free',
],
'time' => Carbon::now()->toDateTimeString()
], 200);
@ -291,6 +296,8 @@ class ShoppingUserController extends Controller
}
$shopping_order->delete();
}
$shopping_user->wp_order_number = time();
$shopping_user->save();
if ($shopping_user->delete()) {
return response()->json([
'success' => true
@ -368,7 +375,7 @@ class ShoppingUserController extends Controller
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email',
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
foreach ($data as $key=>$value){
@ -404,7 +411,7 @@ class ShoppingUserController extends Controller
$ret = [];
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
//'same_as_billing', 'has_buyed', 'subscribed',
'same_as_billing', //'has_buyed', 'subscribed',
'wp_order_number', 'wp_order_date'];
foreach ($needs as $need){
@ -432,10 +439,10 @@ class ShoppingUserController extends Controller
if ($need === 'wp_order_date') {
$ret['wp_order_date'] = Carbon::parse($ret['wp_order_date'])->toDateTimeString();
}
if ($need === 'same_as_billing') {
$ret['same_as_billing'] = isset($data['same_as_billing']) ? $data['same_as_billing'] : true;
}
}
$ret['same_as_billing'] = $ret['shipping_lastname'] !== null ? true : false;
$ret['has_buyed'] = true;
$ret['subscribed'] = false;
return $ret;
@ -490,7 +497,7 @@ class ShoppingUserController extends Controller
'total' => Yard::instance('shopping')->total(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
'tax_rate' => Yard::getTaxRate(),
//'tax_rate' => Yard::getTaxRate(),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'weight' => Yard::instance('shopping')->weight(),
@ -516,6 +523,7 @@ class ShoppingUserController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug,
])->save();
return false;
@ -533,6 +541,7 @@ class ShoppingUserController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug
]);
}

View file

@ -32,7 +32,8 @@ class CardController extends Controller
if($product->images->count()){
$image = $product->images->first()->slug;
}
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product_slug, 'weight' => $product->weight]);
Yard::setTax($cartItem->rowId, $product->tax);
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);
@ -53,7 +54,8 @@ class CardController extends Controller
$image = $product->images->first()->slug;
}
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
Yard::setTax($cartItem->rowId, $product->tax);
Yard::instance('shopping')->reCalculateShippingPrice();
\Session()->flash('show-card-after-add', true);

View file

@ -168,7 +168,7 @@ class CheckoutController extends Controller
if(Request::get('payment_method') === 'elv' && is_null(Request::get('mandate_identification'))){
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') *100;
$amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
if($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID'){
@ -214,7 +214,7 @@ class CheckoutController extends Controller
//other
$pay = new PayoneController();
$pay->init($shopping_user, $shopping_order);
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$amount = Yard::instance('shopping')->totalWithShipping(2, '.', '') * 100;
$reference = $pay->setPrePayment(Request::get('payment_method'), $amount, 'EUR', $ret);
$this->putPayments('payment_reference', $reference);
$pay->setPersonalData();
@ -333,7 +333,7 @@ class CheckoutController extends Controller
'total' => Yard::instance('shopping')->total(2, '.', ''),
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
'subtotal' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
'tax_rate' => Yard::getTaxRate(),
//'tax_rate' => Yard::getTaxRate(),
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'weight' => Yard::instance('shopping')->weight(),
@ -364,6 +364,7 @@ class CheckoutController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug,
])->save();
return false;
@ -380,6 +381,7 @@ class CheckoutController extends Controller
'product_id' => $item->id,
'qty' => $item->qty,
'price' => $item->price,
'tax_rate' => $item->taxRate,
'slug' => $item->options->slug
]);
};