Skip to content

Commit 4b848cb

Browse files
authored
feat(3d-viewer): add custom item display id (#179)
1 parent 2e14f02 commit 4b848cb

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/acore-wp-plugin/src/Hooks/WooCommerce/FieldElements.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public static function get3dViewer(int $itemId = 0): void {
121121
$race = get_post_meta($post->ID, '_3d_race', true);
122122
$gender = get_post_meta($post->ID, '_3d_gender', true);
123123
$gender = $gender === '2' ? rand(0, 1) : $gender;
124-
$creatureDisplayId = get_post_meta($post->ID, '_3d_displayid', true);
124+
$creatureDisplayId = get_post_meta($post->ID, '_3d_npc_displayid', true);
125+
$itemDisplayId = get_post_meta($post->ID, '_3d_item_displayid', true);
125126
$isSingleItem = get_post_meta($post->ID, '_3d_single_item', true) === 'yes';
126127

127128
if ($itemId === 0 && $creatureDisplayId === '') {
@@ -199,6 +200,11 @@ function show3dModel(displayId, entity, inventoryType=0, race=1, gender=0) {
199200
.then(response => response.text())
200201
.then(data => {
201202
let [displayId, entity, inventoryType] = data.split(',');
203+
204+
<?php if ($itemDisplayId !== '') { ?>
205+
displayId = <?= $itemDisplayId ?>;
206+
<?php } ?>
207+
202208
inventoryType = Number(inventoryType);
203209
<?php if ($race !== '' && $gender !== '') { ?>
204210
show3dModel(displayId, entity, inventoryType, <?= $race ?>, <?= $gender ?>);

src/acore-wp-plugin/src/Hooks/WooCommerce/Products.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,19 @@ function add_custom_3d_checkbox_fields() {
2626
));
2727

2828
woocommerce_wp_text_input(array(
29-
'id' => '_3d_displayid',
30-
'label' => __('Force displayid', 'woocommerce'),
29+
'id' => '_3d_npc_displayid',
30+
'label' => __('Force NPC displayid', 'woocommerce'),
3131
'description' => __('Enter a specific Creature displayid.', 'woocommerce'),
3232
'desc_tip' => 'true',
3333
));
34-
34+
35+
woocommerce_wp_text_input(array(
36+
'id' => '_3d_item_displayid',
37+
'label' => __('Force item displayid', 'woocommerce'),
38+
'description' => __('Enter a specific Item displayid.', 'woocommerce'),
39+
'desc_tip' => 'true',
40+
));
41+
3542
woocommerce_wp_select(array(
3643
'id' => '_3d_race',
3744
'label' => __('Race (optional)', 'woocommerce'),
@@ -78,8 +85,11 @@ function save_3d_checkbox_field($post_id) {
7885
$isSingleItem = isset($_POST['_3d_single_item']) ? 'yes' : 'no';
7986
update_post_meta($post_id, '_3d_single_item', $isSingleItem);
8087

81-
$custom_text_input = isset($_POST['_3d_displayid']) ? sanitize_text_field($_POST['_3d_displayid']) : '';
82-
update_post_meta($post_id, '_3d_displayid', $custom_text_input);
88+
$custom_npc_text_input = isset($_POST['_3d_npc_displayid']) ? sanitize_text_field($_POST['_3d_npc_displayid']) : '';
89+
update_post_meta($post_id, '_3d_npc_displayid', $custom_npc_text_input);
90+
91+
$custom_item_text_input = isset($_POST['_3d_item_displayid']) ? sanitize_text_field($_POST['_3d_item_displayid']) : '';
92+
update_post_meta($post_id, '_3d_item_displayid', $custom_item_text_input);
8393

8494
$custom_select = isset($_POST['_3d_race']) ? sanitize_text_field($_POST['_3d_race']) : '';
8595
update_post_meta($post_id, '_3d_race', $custom_select);

0 commit comments

Comments
 (0)