Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rapidez/core into graphql-checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning committed Jan 30, 2024
2 parents e8748f2 + 93c6207 commit 173049d
Show file tree
Hide file tree
Showing 23 changed files with 342 additions and 75 deletions.
63 changes: 62 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
# Changelog

[Unreleased changes](https://github.com/rapidez/core/compare/1.6.1...master)
[Unreleased changes](https://github.com/rapidez/core/compare/1.10.1...master)
## [1.10.1](https://github.com/rapidez/core/releases/tag/1.10.1) - 2024-01-30

### Fixed

- Fix slot scope "limit" to "size" (https://github.com/rapidez/core/pull/412)

## [1.10.0](https://github.com/rapidez/core/releases/tag/1.10.0) - 2024-01-29

### Added

- Add new storecode if directive (https://github.com/rapidez/core/pull/411)
- Add product parent (https://github.com/rapidez/core/pull/404)
- Improve flexibility of additional search queries in autocomplete (https://github.com/rapidez/core/pull/407)

### Changed

- Always set step in checkout success to success step (https://github.com/rapidez/core/pull/403)
- Refresh user before retrieving addresses (https://github.com/rapidez/core/pull/345)

### Fixed

- Fix usage of whitespace tokenizer (https://github.com/rapidez/core/pull/410)


## [1.9.0](https://github.com/rapidez/core/releases/tag/1.9.0) - 2024-01-24

### Changed

- Use the configured locale from Magento (#409)

## [1.8.0](https://github.com/rapidez/core/releases/tag/1.8.0) - 2024-01-23

### Added

- New payment events (#406)
- Robots.txt from Magento config (#408)

### Fixed

- Use stores to get the token and mask on checkout success (#377)
- Fix dusk tests (#405)

## [1.7.1](https://github.com/rapidez/core/releases/tag/1.7.1) - 2024-01-05

### Fixed

- Exclude register themes when running from console (#401)

## [1.7.0](https://github.com/rapidez/core/releases/tag/1.7.0) - 2024-01-04

### Added

- Payment icons (#374)
- Store set event (#398)
- Product review summary model (#399)
- GraphQL components store prop (#400)

### Fixed

- Trigger mounted event for autocomplete to remove timing dependency (#395)

## [1.6.1](https://github.com/rapidez/core/releases/tag/1.6.1) - 2023-12-08

### Fixed
Expand Down
11 changes: 11 additions & 0 deletions config/rapidez/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
'default' => ['cart', 'login', 'credentials', 'payment', 'success'],
],

'autocomplete' => [
// Attach additional indexes to the autocomplete
// Uses the views in rapidez::layouts.partials.header.autocomplete
'additionals' => [
'categories' => ['name^3', 'description'],
],

'debounce' => 100,
'size' => 10,
],

// Link store codes to theme folders
// The structure is `'store_code' => 'folder_path'`
'themes' => [
Expand Down
2 changes: 2 additions & 0 deletions config/rapidez/models.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
'option_value' => Rapidez\Core\Models\OptionValue::class,
'product_image' => Rapidez\Core\Models\ProductImage::class,
'product_image_value' => Rapidez\Core\Models\ProductImageValue::class,
'product_link' => Rapidez\Core\Models\ProductLink::class,
'product_view' => Rapidez\Core\Models\ProductView::class,
'product_option' => Rapidez\Core\Models\ProductOption::class,
'product_option_title' => Rapidez\Core\Models\ProductOptionTitle::class,
'product_option_price' => Rapidez\Core\Models\ProductOptionPrice::class,
'product_option_type_title' => Rapidez\Core\Models\ProductOptionTypeTitle::class,
'product_option_type_price' => Rapidez\Core\Models\ProductOptionTypePrice::class,
'product_option_type_value' => Rapidez\Core\Models\ProductOptionTypeValue::class,
'product_review_summary' => Rapidez\Core\Models\ProductReviewSummary::class,
'quote' => Rapidez\Core\Models\Quote::class,
'quote_id_mask' => Rapidez\Core\Models\QuoteIdMask::class,
'quote_item' => Rapidez\Core\Models\QuoteItem::class,
Expand Down
49 changes: 35 additions & 14 deletions resources/js/components/Checkout/Checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ export default {
this.steps = this.config.checkout_steps[window.config.store_code] ?? this.config.checkout_steps['default']
this.setupHistory()
this.setCheckoutCredentialsFromDefaultUserAddresses()
this.getShippingMethods()
this.getTotalsInformation()
this.$root.$emit('checkout-step', 1)
this.setupCheckout()
},
methods: {
async setupCheckout() {
await this.refreshUser(false)
this.setCheckoutCredentialsFromDefaultUserAddresses()
this.getShippingMethods()
this.getTotalsInformation()
this.$root.$emit('checkout-step', 1)
},
async getShippingMethods() {
let responseData = await this.magentoCart('post', 'estimate-shipping-methods', {
address: {
Expand Down Expand Up @@ -193,6 +200,11 @@ export default {
method: this.checkout.payment_method,
},
})
this.$root.$emit('checkout-payment-selected', {
method: this.checkout.payment_method,
})
this.getTotalsInformation()
},
Expand All @@ -203,22 +215,31 @@ export default {
}
try {
let response = await this.magentoCart('post', 'payment-information', {
billingAddress: this.billingAddress,
shippingAddress: this.shippingAddress,
email: this.user?.email ? this.user.email : this.$root.guestEmail,
paymentMethod: {
method: this.checkout.payment_method,
extension_attributes: {
agreement_ids: this.checkout.agreement_ids,
},
this.$root.$emit('before-checkout-payment-saved', {
order: {
payment_method_code: this.checkout.payment_method,
},
})
let response = {}
if (!window.app.checkout?.preventOrder) {
response = await this.magentoCart('post', 'payment-information', {
billingAddress: this.billingAddress,
shippingAddress: this.shippingAddress,
email: this.user?.email ? this.user.email : this.$root.guestEmail,
paymentMethod: {
method: this.checkout.payment_method,
extension_attributes: {
agreement_ids: this.checkout.agreement_ids,
},
},
})
}
// response.data = orderId
this.$root.$emit('checkout-payment-saved', {
order: {
id: response.data,
id: response?.data,
payment_method_code: this.checkout.payment_method,
},
})
Expand Down
12 changes: 8 additions & 4 deletions resources/js/components/Checkout/CheckoutSuccess.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<script>
import { mask as useMask } from '../../stores/useMask'
import { token as useToken } from '../../stores/useUser'
import { clear as clearCart } from '../../stores/useCart'
export default {
props: {
token: {
type: String,
default: null,
default: useToken.value,
},
mask: {
type: String,
default: null,
default: useMask.value,
},
},
Expand All @@ -24,8 +26,10 @@ export default {
},
created() {
this.token ??= localStorage.token
this.mask ??= localStorage.mask
let successStep = this.$root.config.checkout_steps[this.$root.config.store_code]?.indexOf('success')
if (successStep > 0) {
this.$root.checkout.step = successStep
}
this.refreshOrder().then(() => {
clearCart()
Expand Down
16 changes: 15 additions & 1 deletion resources/js/components/Graphql.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export default {
type: Function,
default: (error) => Notify(window.config.translations.errors.wrong, 'warning'),
},
store: {
type: String,
default: window.config.store_code,
},
},
data: () => ({
Expand Down Expand Up @@ -59,7 +63,17 @@ export default {
async runQuery() {
try {
let response = await window.magentoGraphQL(this.query, this.variables)
let options = {
headers: {},
redirectOnExpiration: true,
notifyOnError: true,
}
if (this.store) {
options['headers']['Store'] = this.store
}
let response = await window.magentoGraphQL(this.query, this.variables, options)
if (this.check) {
if (!eval('response.data.' + this.check)) {
Expand Down
8 changes: 8 additions & 0 deletions resources/js/components/GraphqlMutation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export default {
type: Boolean,
default: false,
},
store: {
type: String,
default: window.config.store_code,
},
},
data: () => ({
Expand Down Expand Up @@ -106,6 +110,10 @@ export default {
options['headers']['Authorization'] = await this.getReCaptchaToken()
}
if (this.store) {
options['headers']['Store'] = this.store
}
let variables = this.data,
query = this.query
Expand Down
74 changes: 57 additions & 17 deletions resources/js/components/Search/Autocomplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,75 @@ export default {
type: Number,
default: 100,
},
},
mounted() {
this.$nextTick(() => this.$emit('mounted'))
size: {
type: Number,
default: 10,
},
multiMatchTypes: {
type: Array,
default: () => ['best_fields', 'phrase', 'phrase_prefix'],
},
},
render() {
return this.$scopedSlots.default(Object.assign(this, { self: this }))
return this.$scopedSlots.default(this)
},
data() {
return {
results: { count: 0 },
results: {},
resultsCount: 0,
searchAdditionals: () => null,
}
},
methods: {
searchAdditionals(query) {
if (!this.additionals) {
mounted() {
this.$nextTick(() => this.$emit('mounted'))
let self = this
// Define function here to gain access to the debounce prop
this.searchAdditionals = useDebounceFn(function (query) {
if (!self.additionals) {
return
}
this.results = { count: 0 }
// Initialize with empty data to preserve additionals order
self.results = Object.fromEntries(Object.keys(self.additionals).map((indexName) => [indexName, []]))
self.resultsCount = 0
let url = new URL(config.es_url)
let auth = `Basic ${btoa(`${url.username}:${url.password}`)}`
let baseUrl = url.origin
Object.entries(this.additionals).forEach(([name, fields]) => {
Object.entries(self.additionals).forEach(([name, data]) => {
let fields = data['fields'] ?? data
let size = data['size'] ?? self.size ?? undefined
let sort = data['sort'] ?? undefined
let multimatch = self.multiMatchTypes.map((type) => ({
multi_match: {
query: query,
type: type,
fields: fields,
fuzziness: type.includes('phrase') ? undefined : 'AUTO',
},
}))
let esQuery = {
size: size,
sort: sort,
query: {
multi_match: {
query: query,
fields: fields,
fuzziness: 'AUTO',
bool: {
should: multimatch,
minimum_should_match: 1,
},
},
highlight: {
pre_tags: ['<mark>'],
post_tags: ['</mark>'],
fields: Object.fromEntries(fields.map((field) => [field.split('^')[0], {}])),
require_field_match: false,
},
}
rapidezFetch(`${baseUrl}/${config.es_prefix}_${name}_${config.store}/_search`, {
Expand All @@ -58,10 +90,18 @@ export default {
}).then(async (response) => {
const responseData = await response.json()
this.results[name] = responseData?.hits ?? []
this.results.count += this.results[name]?.hits?.length ?? 0
self.results[name] = responseData?.hits ?? []
self.results.count += self.results[name]?.hits?.length ?? 0
})
})
}, self.debounce)
},
methods: {
highlight(hit, field) {
let source = hit._source ?? hit.source
let highlight = hit.highlight ?? hit.source.highlight
return highlight?.[field]?.[0] ?? source?.[field] ?? ''
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/checkout/steps/payment.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class="[&+div]:flex-1"
<img
class="ml-auto w-8 h-8"
v-bind:src="`/payment-icons/${method.code}.svg`"
onerror="javascript:this.src=`/payment-icons/default.svg`"
onerror="this.onerror=null; this.src=`/payment-icons/default.svg`"
>
</div>
</x-rapidez::radio>
Expand Down
Loading

0 comments on commit 173049d

Please sign in to comment.