Skip to content

Commit

Permalink
Add package.js, ensure dependency on Vue is satisfied (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning authored Apr 5, 2023
1 parent f5300c5 commit 8d2cb8d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
Implementation of the order comments in the Rapidez checkout.

## Installation
```
```bash
composer require rapidez/boldcommerce-order-comments
```

And include the javascript in `resources/js/app.js`:
```
require('Vendor/rapidez/order-comments/resources/js/order-comments')
```

Add the a textarea to your views in the checkout:
```
```blade
<x-rapidez::textarea v-model="checkout.comment" name="comment" />
```

To display the order comment, usually in the checkout, you can use:
```
```blade
@{{ $root.checkout.comment }}
```
13 changes: 13 additions & 0 deletions resources/js/eventlisteners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'Vendor/rapidez/core/resources/js/app'

document.addEventListener('turbo:load', () => {
Vue.set(window.app.checkout, 'comment', '')

window.app.$on('checkout-credentials-saved', (e) => {
window.app.magentoCart('put', 'set-order-comment', {
orderComment: {
comment: window.app.checkout.comment
}
})
})
})
12 changes: 1 addition & 11 deletions resources/js/order-comments.js
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
document.addEventListener('turbo:load', () => {
Vue.set(window.app.checkout, 'comment', '')

window.app.$on('checkout-credentials-saved', (e) => {
window.app.magentoCart('put', 'set-order-comment', {
orderComment: {
comment: window.app.checkout.comment
}
})
})
})
import './package'
1 change: 1 addition & 0 deletions resources/js/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './eventlisteners'

0 comments on commit 8d2cb8d

Please sign in to comment.