Skip to content

Commit 139e35a

Browse files
fix: keep status copy controls enabled
1 parent 771df60 commit 139e35a

3 files changed

Lines changed: 78 additions & 66 deletions

File tree

src/providers/ShipStationProvider.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ public function getSettingsHtml(): ?string
8989
);
9090
}
9191

92+
public function getSettingsUtilityHtml(): ?string
93+
{
94+
return Craft::$app->getView()->renderTemplate(
95+
'shipments-shipstation/provider-settings-utility',
96+
[
97+
'provider' => $this,
98+
'integration' => $this->getIntegration(),
99+
'statuses' => Status::labelMap(),
100+
],
101+
View::TEMPLATE_MODE_CP,
102+
);
103+
}
104+
92105
public function getShipStationOrderStatus(Shipment $shipment): string
93106
{
94107
$status = $shipment->getStatusEnum();
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<hr>
2+
3+
<h2>ShipStation Status Mapping</h2>
4+
5+
<p>
6+
Copy these status values into ShipStation’s Custom Store form so ShipStation can place imported shipments into the correct buckets.
7+
</p>
8+
9+
<div class="field">
10+
<table class="data fullwidth">
11+
<thead>
12+
<tr>
13+
<th>ShipStation field</th>
14+
<th>Value</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
{% set shipstationStatusRows = {
19+
'Awaiting Payment Status': null,
20+
'Awaiting Shipment Statuses': 'new,in_progress,fulfilled',
21+
'Shipped Status': 'shipped',
22+
'Cancelled Status': 'cancelled',
23+
'On-Hold Status': 'on_hold',
24+
} %}
25+
26+
{% for label, value in shipstationStatusRows %}
27+
<tr>
28+
<td>{{ label }}</td>
29+
<td>
30+
<div style="display: flex; align-items: center; justify-content: space-between; gap: 12px;">
31+
{% if value %}
32+
<code>{{ value }}</code>
33+
<button type="button" class="btn small shipments-shipstation-copy-status" data-copy-value="{{ value }}">
34+
<svg aria-hidden="true" focusable="false" width="14" height="14" viewBox="0 0 16 16" style="vertical-align: -2px; margin-right: 4px;">
35+
<path fill="currentColor" d="M4 2.5A1.5 1.5 0 0 1 5.5 1h7A1.5 1.5 0 0 1 14 2.5v7a1.5 1.5 0 0 1-1.5 1.5H11v1.5A1.5 1.5 0 0 1 9.5 14h-6A1.5 1.5 0 0 1 2 12.5v-6A1.5 1.5 0 0 1 3.5 5H4V2.5ZM5.5 2a.5.5 0 0 0-.5.5V5h4.5A1.5 1.5 0 0 1 11 6.5V10h1.5a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.5-.5h-7ZM3.5 6a.5.5 0 0 0-.5.5v6a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 .5-.5v-6a.5.5 0 0 0-.5-.5h-6Z" />
36+
</svg>
37+
<span>Copy</span>
38+
</button>
39+
{% else %}
40+
<span class="light"><em>Leave as default</em></span>
41+
{% endif %}
42+
</div>
43+
</td>
44+
</tr>
45+
{% endfor %}
46+
</tbody>
47+
</table>
48+
</div>
49+
50+
<script>
51+
(() => {
52+
document.querySelectorAll('.shipments-shipstation-copy-status').forEach((button) => {
53+
button.addEventListener('click', async () => {
54+
const value = button.dataset.copyValue || '';
55+
await navigator.clipboard.writeText(value);
56+
const label = button.querySelector('span');
57+
const originalText = label.textContent;
58+
label.textContent = 'Copied';
59+
setTimeout(() => {
60+
label.textContent = originalText;
61+
}, 1200);
62+
});
63+
});
64+
})();
65+
</script>

src/templates/provider-settings.twig

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -80,69 +80,3 @@
8080
value: provider.phoneNumberFieldHandle,
8181
errors: provider.getErrors('phoneNumberFieldHandle'),
8282
}) }}
83-
84-
<hr>
85-
86-
<h2>ShipStation Status Mapping</h2>
87-
88-
<p>
89-
Copy these status values into ShipStation’s Custom Store form so ShipStation can place imported shipments into the correct buckets.
90-
</p>
91-
92-
<div class="field">
93-
<table class="data fullwidth">
94-
<thead>
95-
<tr>
96-
<th>ShipStation field</th>
97-
<th>Value</th>
98-
</tr>
99-
</thead>
100-
<tbody>
101-
{% set shipstationStatusRows = {
102-
'Awaiting Payment Status': null,
103-
'Awaiting Shipment Statuses': 'new,in_progress,fulfilled',
104-
'Shipped Status': 'shipped',
105-
'Cancelled Status': 'cancelled',
106-
'On-Hold Status': 'on_hold',
107-
} %}
108-
109-
{% for label, value in shipstationStatusRows %}
110-
<tr>
111-
<td>{{ label }}</td>
112-
<td>
113-
<div style="display: flex; align-items: center; justify-content: space-between; gap: 12px;">
114-
{% if value %}
115-
<code>{{ value }}</code>
116-
<button type="button" class="btn small shipments-shipstation-copy-status" data-copy-value="{{ value }}">
117-
<svg aria-hidden="true" focusable="false" width="14" height="14" viewBox="0 0 16 16" style="vertical-align: -2px; margin-right: 4px;">
118-
<path fill="currentColor" d="M4 2.5A1.5 1.5 0 0 1 5.5 1h7A1.5 1.5 0 0 1 14 2.5v7a1.5 1.5 0 0 1-1.5 1.5H11v1.5A1.5 1.5 0 0 1 9.5 14h-6A1.5 1.5 0 0 1 2 12.5v-6A1.5 1.5 0 0 1 3.5 5H4V2.5ZM5.5 2a.5.5 0 0 0-.5.5V5h4.5A1.5 1.5 0 0 1 11 6.5V10h1.5a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.5-.5h-7ZM3.5 6a.5.5 0 0 0-.5.5v6a.5.5 0 0 0 .5.5h6a.5.5 0 0 0 .5-.5v-6a.5.5 0 0 0-.5-.5h-6Z" />
119-
</svg>
120-
<span>Copy</span>
121-
</button>
122-
{% else %}
123-
<span class="light"><em>Leave as default</em></span>
124-
{% endif %}
125-
</div>
126-
</td>
127-
</tr>
128-
{% endfor %}
129-
</tbody>
130-
</table>
131-
</div>
132-
133-
<script>
134-
(() => {
135-
document.querySelectorAll('.shipments-shipstation-copy-status').forEach((button) => {
136-
button.addEventListener('click', async () => {
137-
const value = button.dataset.copyValue || '';
138-
await navigator.clipboard.writeText(value);
139-
const label = button.querySelector('span');
140-
const originalText = label.textContent;
141-
label.textContent = 'Copied';
142-
setTimeout(() => {
143-
label.textContent = originalText;
144-
}, 1200);
145-
});
146-
});
147-
})();
148-
</script>

0 commit comments

Comments
 (0)