Started with convert x to product id for cart rules

This commit is contained in:
Prashant Singh 2019-07-13 15:23:27 +05:30
parent 7ffbee95ad
commit f8c774b3a5
11 changed files with 85 additions and 49 deletions

View File

@ -99,7 +99,6 @@
"extra": { "extra": {
"laravel": { "laravel": {
"dont-discover": [ "dont-discover": [
"laravel/dusk",
"barryvdh/laravel-debugbar" "barryvdh/laravel-debugbar"
] ]
} }

View File

@ -818,7 +818,10 @@ return [
'select-attr' => 'Select Attribute', 'select-attr' => 'Select Attribute',
'select-attr-fam' => 'Select Attribute Family', 'select-attr-fam' => 'Select Attribute Family',
'select-cart-attr' => 'Select Cart Attribute', 'select-cart-attr' => 'Select Cart Attribute',
'select-products' => 'Select product attributes',
'select-category' => 'Select Categories',
'general-info' => [ 'general-info' => [
'sku-like' => 'SKU Like',
'on-shipping' => 'If applied on shipping', 'on-shipping' => 'If applied on shipping',
'discount' => 'Discount', 'discount' => 'Discount',
'to-be-applied' => 'Applied On', 'to-be-applied' => 'Applied On',

View File

@ -341,6 +341,30 @@
</div> </div>
</accordian> </accordian>
<accordian :active="true" title="{{ __('admin::app.promotion.select-products') }}">
<div slot="body">
<div class="control-group" :class="[errors.has('categories') ? 'has-error' : '']">
<label class="mb-10" for="categories">{{ __('admin::app.promotion.select-category') }}</label>
<multiselect v-model="categories" :options="options" :searchable="false" :close-on-select="false" :allow-empty="true" :show-labels="true" placeholder="Select Categories" :multiple="true" :hide-selected="true" :taggable="true" @tag="addTag"></multiselect>
<pre>
<code>@{{ value }}</code>
</pre>
</div>
<div class="control-group" :class="[errors.has('attributes') ? 'has-error' : '']">
<label class="mb-10" for="attributes">{{ __('admin::app.promotion.select-category') }}</label>
<multiselect v-model="attributes" :options="options" :searchable="false" :close-on-select="false" :allow-empty="true" :show-labels="true" placeholder="Select Categories" :multiple="true" :hide-selected="true" :taggable="true" @tag="addTag"></multiselect>
<pre>
<code>@{{ value }}</code>
</pre>
</div>
</div>
</accordian>
<accordian :active="false" :title="'{{ __('admin::app.promotion.general-info.labels') }}'"> <accordian :active="false" :title="'{{ __('admin::app.promotion.general-info.labels') }}'">
<div slot="body"> <div slot="body">
<div class="control-group" :class="[errors.has('label') ? 'has-error' : '']" v-if="dedicated_label"> <div class="control-group" :class="[errors.has('label') ? 'has-error' : '']" v-if="dedicated_label">
@ -380,6 +404,10 @@
data () { data () {
return { return {
options: [
1, 2, 3, 4, 5, 6
],
categories: null,
name: null, name: null,
description: null, description: null,
conditions_list: [], conditions_list: [],
@ -441,6 +469,16 @@
methods: { methods: {
addTag (newTag) {
const tag = {
name: newTag,
code: newTag.substring(0, 2) + Math.floor((Math.random() * 10000000))
}
this.options.push(tag)
this.value.push(tag)
},
addCondition () { addCondition () {
if (this.criteria == 'product_subselection' || this.criteria == 'cart') { if (this.criteria == 'product_subselection' || this.criteria == 'cart') {
this.condition_on = this.criteria; this.condition_on = this.criteria;
@ -524,5 +562,11 @@
} }
}); });
</script> </script>
<style>
pre {
position: absolute;
}
</style>
@endpush @endpush
@stop @stop

View File

@ -394,9 +394,9 @@ class Core
if (is_null($amount)) if (is_null($amount))
$amount = 0; $amount = 0;
$formater = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY ); $formatter = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY );
return $formater->formatCurrency($this->convertPrice($amount), $this->getCurrentCurrency()->code); return $formatter->formatCurrency($this->convertPrice($amount), $this->getCurrentCurrency()->code);
} }
/** /**
@ -424,9 +424,9 @@ class Core
if (is_null($price)) if (is_null($price))
$price = 0; $price = 0;
$formater = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY ); $formatter = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY );
return $formater->formatCurrency($price, $currencyCode); return $formatter->formatCurrency($price, $currencyCode);
} }
/** /**
@ -440,9 +440,9 @@ class Core
if (is_null($price)) if (is_null($price))
$price = 0; $price = 0;
$formater = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY ); $formatter = new \NumberFormatter( app()->getLocale(), \NumberFormatter::CURRENCY );
return $formater->formatCurrency($price, $this->getBaseCurrencyCode()); return $formatter->formatCurrency($price, $this->getBaseCurrencyCode());
} }
/** /**

View File

@ -36,30 +36,8 @@ return [
'value' => null 'value' => null
] ]
], ],
'info' => 'admin::app.promotion.general-info.applied-on-info' 'info' => 'admin::app.promotion.general-info.applied-on-info'
], [
'name' => 'on_shipping',
'title' => 'admin::app.promotion.general-info.on-shipping',
'type' => 'select',
'validation' => 'required',
'channel_based' => true,
'locale_based' => false,
'options' => [
[
'title' => 'On grand-total',
'value' => 0
], [
'title' => 'On selected item',
'value' => 1
], [
'title' => 'On sub-total',
'value' => 2
], [
'title' => 'Please select an option',
'value' => null
]
],
'info' => 'admin::app.promotion.general-info.shipping-apply-info'
] ]
] ]
], ],

View File

@ -23,6 +23,7 @@
"tooltip.js": "^1.3.1", "tooltip.js": "^1.3.1",
"url-polyfill": "^1.1.5", "url-polyfill": "^1.1.5",
"url-search-params-polyfill": "^6.0.0", "url-search-params-polyfill": "^6.0.0",
"vue-multiselect": "^2.1.6",
"vue-swatches": "^1.0.3" "vue-swatches": "^1.0.3"
} }
} }

View File

@ -19,10 +19,15 @@ Vue.component("date", require("./components/date"));
Vue.component("swatch-picker", require("./components/swatch-picker")); Vue.component("swatch-picker", require("./components/swatch-picker"));
Vue.directive("debounce", require("./directives/debounce")); Vue.directive("debounce", require("./directives/debounce"));
import { Multiselect } from 'vue-multiselect';
Vue.component('multiselect', Multiselect);
require('flatpickr/dist/flatpickr.css'); require('flatpickr/dist/flatpickr.css');
require('vue-swatches/dist/vue-swatches.min.css'); require('vue-swatches/dist/vue-swatches.min.css');
require('vue-multiselect/dist/vue-multiselect.min.css');
require("@babel/polyfill"); require("@babel/polyfill");
require('url-search-params-polyfill'); require('url-search-params-polyfill');

View File

@ -15,12 +15,18 @@ class ExampleTest extends DuskTestCase
*/ */
public function testBasicExample() public function testBasicExample()
{ {
$this->browse(function (Browser $browser) { $customer = app('Webkul\Customer\Repositories\CustomerRepository');
$customer = $customer->all();
$customer = $customer->first();
$this->browse(function (Browser $browser) use($customer) {
$browser->visit('/customer/login') $browser->visit('/customer/login')
->type('email', 'john@doe.net') ->type('email', $customer->email)
->type('password', '12345678') ->type('password', $customer->password)
->click('input[type="submit"]') ->click('input[type="submit"]')
->screenshot('error'); ->screenshot('error');
}); });
} }
} }

View File

@ -24,7 +24,7 @@ class AuthTest extends TestCase
*/ */
public function testCustomerLoginPage() public function testCustomerLoginPage()
{ {
config(['app.url' => 'http://127.0.0.1:8000']); config(['app.url' => 'http://prashant.com']);
$response = $this->get('/customer/login'); $response = $this->get('/customer/login');
@ -33,8 +33,9 @@ class AuthTest extends TestCase
$response->assertViewIs('shop::customers.session.index'); $response->assertViewIs('shop::customers.session.index');
} }
public function testCustomerResgistrationPage() { public function testCustomerResgistrationPage()
config(['app.url' => 'http://127.0.0.1:8000']); {
config(['app.url' => 'http://prashant.com']);
$response = $this->get('/customer/register'); $response = $this->get('/customer/register');
@ -64,8 +65,9 @@ class AuthTest extends TestCase
$this->assertEquals($created->id, $created->id); $this->assertEquals($created->id, $created->id);
} }
public function testCustomerLogin() { public function testCustomerLogin()
config(['app.url' => 'http://127.0.0.1:8000']); {
config(['app.url' => 'http://prashant.com']);
$customers = app(Customer::class); $customers = app(Customer::class);
$customer = $customers->findOneByField('email', 'john@doe.net'); $customer = $customers->findOneByField('email', 'john@doe.net');
@ -115,8 +117,6 @@ class AuthTest extends TestCase
{ {
$customer = auth()->guard('customer')->user(); $customer = auth()->guard('customer')->user();
// dd('logout test', $customer);
$this->get(route('customer.session.destroy')); $this->get(route('customer.session.destroy'));
$this->assertGuest(); $this->assertGuest();

View File

@ -21,7 +21,7 @@ class GeneralTest extends TestCase
*/ */
public function testHomePage() public function testHomePage()
{ {
config(['app.url' => 'http://127.0.0.1:8000']); config(['app.url' => 'http://prashant.com']);
$response = $this->get('/'); $response = $this->get('/');
@ -35,7 +35,7 @@ class GeneralTest extends TestCase
*/ */
public function testCustomerLoginPage() public function testCustomerLoginPage()
{ {
config(['app.url' => 'http://127.0.0.1:8000']); config(['app.url' => 'http://prashant.com']);
$response = $this->get('/customer/login'); $response = $this->get('/customer/login');
@ -51,7 +51,7 @@ class GeneralTest extends TestCase
{ {
$categoryUrlSlug = 'marvel-figurines'; $categoryUrlSlug = 'marvel-figurines';
config(['app.url' => 'http://127.0.0.1:8000']); config(['app.url' => 'http://prashant.com']);
$response = $this->get("/categories/{$categoryUrlSlug}"); $response = $this->get("/categories/{$categoryUrlSlug}");
@ -65,7 +65,7 @@ class GeneralTest extends TestCase
*/ */
public function testCustomerRegistrationPage() public function testCustomerRegistrationPage()
{ {
config(['app.url' => 'http://127.0.0.1:8000']); // config(['app.url' => 'http://127.0.0.1:8000']);
$response = $this->get("/customer/register"); $response = $this->get("/customer/register");
@ -79,7 +79,7 @@ class GeneralTest extends TestCase
*/ */
public function testCartPage() public function testCartPage()
{ {
config(['app.url' => 'http://127.0.0.1:8000']); // config(['app.url' => 'http://127.0.0.1:8000']);
$response = $this->get("/checkout/cart"); $response = $this->get("/checkout/cart");