mkfashion-sdk 2.2.9 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.html +67 -47
- package/package.json +1 -1
- package/src/mkfashion.js +81 -432
- package/.claude/settings.local.json +0 -9
- package/.claude/worktrees/ecstatic-volhard/.claude/settings.local.json +0 -24
- package/.claude/worktrees/ecstatic-volhard/.gitattributes +0 -2
- package/.claude/worktrees/ecstatic-volhard/.vscode/launch.json +0 -15
- package/.claude/worktrees/ecstatic-volhard/index.html +0 -67
- package/.claude/worktrees/ecstatic-volhard/package.json +0 -18
- package/.claude/worktrees/ecstatic-volhard/src/mkfashion.js +0 -1014
- package/.claude/worktrees/zealous-jennings/.claude/settings.local.json +0 -18
- package/.claude/worktrees/zealous-jennings/.gitattributes +0 -2
- package/.claude/worktrees/zealous-jennings/.vscode/launch.json +0 -15
- package/.claude/worktrees/zealous-jennings/index.html +0 -67
- package/.claude/worktrees/zealous-jennings/package.json +0 -18
- package/.claude/worktrees/zealous-jennings/src/mkfashion.js +0 -1037
- package/.vscode/launch.json +0 -15
package/index.html
CHANGED
|
@@ -1,67 +1,87 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
2
|
+
<html lang="pt-BR">
|
|
4
3
|
<head>
|
|
5
4
|
<meta charset="UTF-8">
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
<script src="
|
|
9
|
-
<!-- Para produção, use o CDN: -->
|
|
10
|
-
<!-- <script src="https://unpkg.com/mkfashion-sdk/src/mkfashion.js"></script> -->
|
|
11
|
-
<style>
|
|
12
|
-
.btn-provar {
|
|
13
|
-
background: #000;
|
|
14
|
-
color: #fff;
|
|
15
|
-
padding: 12px 24px;
|
|
16
|
-
border: none;
|
|
17
|
-
border-radius: 8px;
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
font-size: 16px;
|
|
20
|
-
display: none;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.btn-provar:hover {
|
|
24
|
-
background: #333;
|
|
25
|
-
}
|
|
26
|
-
</style>
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Provador Virtual</title>
|
|
7
|
+
<script src="https://unpkg.com/mkfashion-sdk/src/mkfashion.js"></script>
|
|
27
8
|
</head>
|
|
28
|
-
|
|
29
9
|
<body>
|
|
30
10
|
|
|
31
|
-
<
|
|
32
|
-
<p>SKU: 165230</p>
|
|
33
|
-
|
|
34
|
-
<button class="btn-provar" id="btn-provar">
|
|
35
|
-
Provador Virtual
|
|
36
|
-
</button>
|
|
11
|
+
<button id="btn-provar" style="display: none;">Provar Virtualmente</button>
|
|
37
12
|
|
|
38
13
|
<script>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
14
|
+
(function() {
|
|
15
|
+
var projectid = '698c7cc61d3129430f15dddc';
|
|
16
|
+
var identifier = '16255';
|
|
17
|
+
|
|
18
|
+
function initMkFashion() {
|
|
19
|
+
mkfashion.addToCart(function(payload) {
|
|
20
|
+
console.log('Adicionando ao carrinho:', payload);
|
|
21
|
+
|
|
22
|
+
var variantSku = payload.selectedIdentifier;
|
|
42
23
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
fetch('/cart/add.js', {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
items: [{
|
|
31
|
+
quantity: 1,
|
|
32
|
+
id: variantSku
|
|
33
|
+
}]
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
.then(function(response) {
|
|
37
|
+
return response.json();
|
|
38
|
+
})
|
|
39
|
+
.then(function(data) {
|
|
40
|
+
console.log('Produto adicionado:', data);
|
|
41
|
+
// document.dispatchEvent(new CustomEvent('cart:updated'));
|
|
42
|
+
})
|
|
43
|
+
.catch(function(error) {
|
|
44
|
+
console.error('Erro carrinho:', error);
|
|
45
|
+
});
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
mkfashion.isAvailable(projectid, identifier)
|
|
49
|
+
.then(function(disponivel) {
|
|
50
|
+
if (disponivel) {
|
|
51
|
+
var button = document.getElementById('btn-provar');
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
btn.style.display = 'inline-block';
|
|
53
|
+
if (button) {
|
|
54
|
+
button.style.display = 'inline-block';
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
button.onclick = function() {
|
|
57
|
+
mkfashion.open({
|
|
58
|
+
projectid: projectid,
|
|
59
|
+
identifier: identifier
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
.catch(function(error) {
|
|
66
|
+
console.error('Erro disponibilidade MK Fashion:', error);
|
|
57
67
|
});
|
|
58
|
-
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function waitForMkFashion() {
|
|
71
|
+
if (typeof mkfashion !== 'undefined') {
|
|
72
|
+
initMkFashion();
|
|
73
|
+
} else {
|
|
74
|
+
setTimeout(waitForMkFashion, 100);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (document.readyState === "loading") {
|
|
79
|
+
document.addEventListener("DOMContentLoaded", waitForMkFashion);
|
|
59
80
|
} else {
|
|
60
|
-
|
|
81
|
+
waitForMkFashion();
|
|
61
82
|
}
|
|
62
|
-
});
|
|
83
|
+
})();
|
|
63
84
|
</script>
|
|
64
85
|
|
|
65
86
|
</body>
|
|
66
|
-
|
|
67
87
|
</html>
|