Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/acore-wp-plugin/src/Hooks/WooCommerce/FieldElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public static function get3dViewer(int $itemId = 0): void {
$race = get_post_meta($post->ID, '_3d_race', true);
$gender = get_post_meta($post->ID, '_3d_gender', true);
$gender = $gender === '2' ? rand(0, 1) : $gender;
$creatureDisplayId = get_post_meta($post->ID, '_3d_displayid', true);
$creatureDisplayId = get_post_meta($post->ID, '_3d_npc_displayid', true);
$itemDisplayId = get_post_meta($post->ID, '_3d_item_displayid', true);
$isSingleItem = get_post_meta($post->ID, '_3d_single_item', true) === 'yes';

if ($itemId === 0 && $creatureDisplayId === '') {
Expand Down Expand Up @@ -199,6 +200,11 @@ function show3dModel(displayId, entity, inventoryType=0, race=1, gender=0) {
.then(response => response.text())
.then(data => {
let [displayId, entity, inventoryType] = data.split(',');

<?php if ($itemDisplayId !== '') { ?>
displayId = <?= $itemDisplayId ?>;
<?php } ?>

inventoryType = Number(inventoryType);
<?php if ($race !== '' && $gender !== '') { ?>
show3dModel(displayId, entity, inventoryType, <?= $race ?>, <?= $gender ?>);
Expand Down
20 changes: 15 additions & 5 deletions src/acore-wp-plugin/src/Hooks/WooCommerce/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@ function add_custom_3d_checkbox_fields() {
));

woocommerce_wp_text_input(array(
'id' => '_3d_displayid',
'label' => __('Force displayid', 'woocommerce'),
'id' => '_3d_npc_displayid',
'label' => __('Force NPC displayid', 'woocommerce'),
'description' => __('Enter a specific Creature displayid.', 'woocommerce'),
'desc_tip' => 'true',
));


woocommerce_wp_text_input(array(
'id' => '_3d_item_displayid',
'label' => __('Force item displayid', 'woocommerce'),
'description' => __('Enter a specific Item displayid.', 'woocommerce'),
'desc_tip' => 'true',
));

woocommerce_wp_select(array(
'id' => '_3d_race',
'label' => __('Race (optional)', 'woocommerce'),
Expand Down Expand Up @@ -78,8 +85,11 @@ function save_3d_checkbox_field($post_id) {
$isSingleItem = isset($_POST['_3d_single_item']) ? 'yes' : 'no';
update_post_meta($post_id, '_3d_single_item', $isSingleItem);

$custom_text_input = isset($_POST['_3d_displayid']) ? sanitize_text_field($_POST['_3d_displayid']) : '';
update_post_meta($post_id, '_3d_displayid', $custom_text_input);
$custom_npc_text_input = isset($_POST['_3d_npc_displayid']) ? sanitize_text_field($_POST['_3d_npc_displayid']) : '';
update_post_meta($post_id, '_3d_npc_displayid', $custom_npc_text_input);

$custom_item_text_input = isset($_POST['_3d_item_displayid']) ? sanitize_text_field($_POST['_3d_item_displayid']) : '';
update_post_meta($post_id, '_3d_item_displayid', $custom_item_text_input);

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