Skip to content

Commit 8cf000f

Browse files
committed
Merge branch 'main' of github.com:astrogoat/postscript
2 parents 7b6db80 + ac97640 commit 8cf000f

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postscript",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "[![Latest Version on Packagist](https://img.shields.io/packagist/v/astrogoat/postscript.svg?style=flat-square)](https://packagist.org/packages/astrogoat/postscript) [![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/astrogoat/postscript/run-tests?label=tests)](https://github.com/astrogoat/postscript/actions?query=workflow%3Arun-tests+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/astrogoat/postscript/Check%20&%20fix%20styling?label=code%20style)](https://github.com/astrogoat/postscript/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain) [![Total Downloads](https://img.shields.io/packagist/dt/astrogoat/postscript.svg?style=flat-square)](https://packagist.org/packages/astrogoat/postscript)",
55
"directories": {
66
"test": "tests"

resources/views/script.blade.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
11
@if(\Astrogoat\Postscript\Settings\PostscriptSettings::isEnabled() && ! blank(settings('Astrogoat\\Postscript\\Settings\\PostscriptSettings', 'shop_id')))
22
<script async src="https://sdk.postscript.io/sdk.bundle.js?shopId={{settings('Astrogoat\\Postscript\\Settings\\PostscriptSettings', 'shop_id')}}"></script>
3+
<script defer>
4+
window.addEventListener('item-added-to-cart', (event) => {
5+
window.postscript.event('add_to_cart', {
6+
"shop_id": {{ settings(Astrogoat\Postscript\Settings\PostscriptSettings::class, 'shop_id') }},
7+
"url": '{{ request()->url() }}',
8+
"search_params": {"variant": event.detail.id},
9+
"page_type": "product",
10+
"referrer": "{{ request()->headers->get('referer') }}",
11+
"resource": {
12+
"category": event.detail.type,
13+
"name": event.detail.title,
14+
"price_in_cents": event.detail.price,
15+
"resource_id": event.detail.product_id,
16+
"resource_type": "product",
17+
"sku": event.detail.sku,
18+
"variant_id": event.detail.id,
19+
}
20+
});
21+
});
22+
23+
function postscriptPageView(data) {
24+
window.addEventListener("postscriptReady", function(ev) {
25+
window.postscript.event('page_view', {
26+
"shop_id": {{ settings(Astrogoat\Postscript\Settings\PostscriptSettings::class, 'shop_id') }},
27+
"url": '{{ request()->url() }}',
28+
"search_params": {"variant": data.variant_id},
29+
"page_type": "product",
30+
"referrer": "{{ request()->headers->get('referer') }}",
31+
"resource": {
32+
"category": data.type,
33+
"name": data.name,
34+
"price_in_cents": data.price,
35+
"resource_id": data.product_id,
36+
"resource_type": "product",
37+
"sku": data.sku,
38+
"variant_id": data.variant_id,
39+
}
40+
});
41+
})
42+
}
43+
</script>
344
@endif

0 commit comments

Comments
 (0)