Skip to content

Commit 9ca241d

Browse files
authored
release: fixes
- Fixed an issue where fields in a meta group could not be reordered, and changes to the field order were not saved. - Fixed an issue where the category assigned to a PPOM meta field in the 'Product Meta Basic Settings' page was not being saved in certain conditions. - Fixed an issue where hidden input fields were incorrectly included in the price calculation at checkout, leading to an incorrect total when switching between price sets.
2 parents af87f35 + 3f62994 commit 9ca241d

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

.distignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ composer.lock
2323
.idea
2424
**/*.css.map
2525
.DS_Store
26-
.gitkeep
26+
.gitkeep
27+
.wordpress-org

classes/frontend-scripts.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ public static function load_scripts_by_product_id( $product_id, $ppom_id = null,
507507
array(
508508
'jquery',
509509
'ppom-inputs',
510-
)
510+
),
511+
PPOM_VERSION
511512
);
512513

513514
self::set_localize_data( $ppom_conditions_script, 'ppom_input_vars', $product, $input_js_vars, $global_js_vars );

inc/admin.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ function ppom_admin_save_form_meta() {
276276
}
277277

278278
$_REQUEST['ppom'] = is_array( $_REQUEST['ppom'] ) ? $_REQUEST['ppom'] : json_decode( wp_unslash( $_REQUEST['ppom'] ), true );
279+
279280
global $wpdb;
280281

281282
extract( $_REQUEST );
@@ -312,8 +313,6 @@ function( $pm ) {
312313
$aviary_api_key = isset( $_REQUEST['aviary_api_key'] ) ? sanitize_text_field( $_REQUEST['aviary_api_key'] ) : '';
313314
$productmeta_style = isset( $_REQUEST['productmeta_style'] ) ? sanitize_text_field( $_REQUEST['productmeta_style'] ) : '';
314315
$productmeta_js = isset( $_REQUEST['productmeta_js'] ) ? sanitize_text_field( $_REQUEST['productmeta_js'] ) : '';
315-
$productmeta_categories = isset( $_REQUEST['productmeta_categories'] ) ? sanitize_textarea_field( $_REQUEST['productmeta_categories'] ) : '';
316-
317316

318317
if ( strlen( $productmeta_name ) > 50 ) {
319318
$resp = array(
@@ -330,7 +329,6 @@ function( $pm ) {
330329
'send_file_attachment' => $send_file_attachment,
331330
'show_cart_thumb' => $show_cart_thumb,
332331
'aviary_api_key' => trim( $aviary_api_key ),
333-
'productmeta_categories' => $productmeta_categories,
334332
'the_meta' => $product_meta,
335333
'productmeta_created' => current_time( 'mysql' ),
336334
);
@@ -453,6 +451,7 @@ function ppom_admin_update_form_meta() {
453451
wp_send_json( $resp );
454452
}
455453
$_REQUEST['ppom'] = is_array( $_REQUEST['ppom'] ) ? $_REQUEST['ppom'] : json_decode( wp_unslash( $_REQUEST['ppom'] ), true );
454+
456455
global $wpdb;
457456

458457
$ppom_meta = isset( $_REQUEST['ppom_meta'] ) ? $_REQUEST['ppom_meta'] : $_REQUEST['ppom'];
@@ -474,7 +473,6 @@ function( $pm ) {
474473
$aviary_api_key = isset( $_REQUEST['aviary_api_key'] ) ? sanitize_text_field( $_REQUEST['aviary_api_key'] ) : '';
475474
$productmeta_style = isset( $_REQUEST['productmeta_style'] ) ? sanitize_text_field( $_REQUEST['productmeta_style'] ) : '';
476475
$productmeta_js = isset( $_REQUEST['productmeta_js'] ) ? sanitize_text_field( $_REQUEST['productmeta_js'] ) : '';
477-
$productmeta_categories = isset( $_REQUEST['productmeta_categories'] ) ? sanitize_textarea_field( $_REQUEST['productmeta_categories'] ) : '';
478476

479477
if ( strlen( $productmeta_name ) > 50 ) {
480478
$resp = array(
@@ -491,7 +489,6 @@ function( $pm ) {
491489
'send_file_attachment' => $send_file_attachment,
492490
'show_cart_thumb' => $show_cart_thumb,
493491
'aviary_api_key' => trim( $aviary_api_key ),
494-
'productmeta_categories' => $productmeta_categories,
495492
'the_meta' => $product_meta,
496493
);
497494
if ( ! ppom_is_legacy_user() ) {

js/admin/ppom-admin.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,14 @@ jQuery(function($) {
128128
jQuery(".ppom-meta-save-notice").html('<img src="' + ppom_vars.loader + '">').show();
129129

130130
$('.ppom-unsave-data').remove();
131-
var data = $(this).serializeJSON();
131+
const data = $(this).serializeJSON();
132+
133+
const fieldsOrder = Array(...document.querySelectorAll('.ui-sortable-handle[id^="ppom_sort_id_"]'))
134+
.map( node => node.id.replace('ppom_sort_id_', '') ); // ['2', '3']
135+
data.ppom = fieldsOrder.map( fieldId => data.ppom[fieldId] );
136+
132137
data.ppom = JSON.stringify(data.ppom);
138+
133139
// Send the JSON data via POST request
134140
$.ajax({
135141
url: ajaxurl,
@@ -329,7 +335,7 @@ jQuery(function($) {
329335
placeholder = '-';
330336
}
331337

332-
var html = '<tr class="row_no_' + id + '" id="ppom_sort_id_' + id + '">';
338+
var html = '<tr class="row_no_' + id + ' ui-sortable-handle" id="ppom_sort_id_' + id + '">';
333339
html += '<td class="ppom-sortable-handle"><i class="fa fa-arrows" aria-hidden="true"></i></td>';
334340
html += '<td class="ppom-check-one-field ppom-checkboxe-style">';
335341
html += '<label>';

js/ppom-conditions-v2.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ jQuery(function($) {
6161

6262
const data_name = modifiedElement.dataset?.data_name;
6363
ppom_check_conditions(data_name, (element_dataname, event_type) => {
64-
const event = new CustomEvent(event_type, {
65-
detail: {
66-
field: element_dataname,
67-
time: new Date()
68-
}
64+
$.event.trigger({
65+
type: event_type,
66+
field: element_dataname,
67+
time: new Date()
6968
});
70-
document.dispatchEvent(event);
7169
});
7270
}
7371

0 commit comments

Comments
 (0)