Country Prices | Homeparty | Shop | Order
This commit is contained in:
parent
51d81d8ec6
commit
39d1e93416
284 changed files with 784 additions and 216 deletions
|
|
@ -2,21 +2,23 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailReleaseAccount;
|
||||
use App\Models\File;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Repositories\FileRepository;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use Validator;
|
||||
use Yard;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Models\File;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Services\UserService;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Mail\MailReleaseAccount;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Repositories\FileRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class WizardController extends Controller
|
||||
{
|
||||
|
|
@ -119,6 +121,15 @@ class WizardController extends Controller
|
|||
}
|
||||
|
||||
$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
}
|
||||
|
||||
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
|
||||
//Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
|
||||
//Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
|
||||
|
||||
$data = [
|
||||
'user' => Auth::user(),
|
||||
|
|
@ -126,8 +137,10 @@ class WizardController extends Controller
|
|||
'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(),
|
||||
'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(),
|
||||
'userHistoryWizardPayment' => $userHistoryWizardPayment,
|
||||
'yard_info' => UserService::getYardInfo(),
|
||||
];
|
||||
|
||||
|
||||
if($user->wizard == 20){
|
||||
return view('user.wizard.register_payment', $data);
|
||||
}
|
||||
|
|
@ -135,6 +148,22 @@ class WizardController extends Controller
|
|||
return redirect(route('/'));
|
||||
}
|
||||
|
||||
private function checkShoppingCountry($user ){
|
||||
|
||||
$country_id = null;
|
||||
if($user->account->same_as_billing){
|
||||
$country_id = $user->account->country_id;
|
||||
}else{
|
||||
$country_id = $user->account->shipping_country_id;
|
||||
}
|
||||
if($country_id){
|
||||
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
return $shipping_country->id;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function storeRegister($step = false)
|
||||
{
|
||||
|
||||
|
|
@ -433,14 +462,30 @@ class WizardController extends Controller
|
|||
$user->save();
|
||||
}
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
}
|
||||
|
||||
UserService::checkUserTaxShippingCountry($user, $shipping_country_id);
|
||||
Yard::instance('shopping')->setUserPriceInfos(UserService::getYardInfo());
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id);
|
||||
|
||||
|
||||
if($product && $product->active){
|
||||
//set membership product
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
|
||||
//set onboarding products
|
||||
if(Request::get('products_on_board')){
|
||||
foreach (Request::get('products_on_board') as $product_on_board_id){
|
||||
|
|
@ -449,7 +494,12 @@ class WizardController extends Controller
|
|||
if($product_on_board->images->count()){
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->price, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(\App\Services\UserService::$user_country));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -457,11 +507,10 @@ class WizardController extends Controller
|
|||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'wizard';
|
||||
$data['is_for'] = 'me';
|
||||
|
||||
$data['user_price_infos'] = \App\Services\UserService::getUserPriceInfos();
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue