feat: integrate yandex metrika ecommerce
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {isNotEmpty} from "@/helpers.js";
|
||||
import {addToCart, cartEditItem, cartRemoveItem, getCart, setCoupon, setVoucher} from "@/utils/ftch.js";
|
||||
import {useYaMetrikaStore} from "@/stores/yaMetrikaStore.js";
|
||||
import {useSettingsStore} from "@/stores/SettingsStore.js";
|
||||
|
||||
export const useCartStore = defineStore('cart', {
|
||||
state: () => ({
|
||||
@@ -79,12 +81,27 @@ export const useCartStore = defineStore('cart', {
|
||||
}
|
||||
},
|
||||
|
||||
async removeItem(rowId) {
|
||||
async removeItem(cartItem, rowId, index = 0) {
|
||||
try {
|
||||
this.isLoading = true;
|
||||
const formData = new FormData();
|
||||
formData.append('key', rowId);
|
||||
await cartRemoveItem(formData);
|
||||
useYaMetrikaStore().dataLayerPush({
|
||||
"ecommerce": {
|
||||
"currencyCode": useSettingsStore().currency_code,
|
||||
"remove": {
|
||||
"products": [
|
||||
{
|
||||
"id": cartItem.product_id,
|
||||
"name": cartItem.name,
|
||||
"quantity": cartItem.quantity,
|
||||
"position": index
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
await this.getProducts();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user