Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
selul authored Oct 8, 2024
2 parents af87f35 + 3f62994 commit 9ca241d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ composer.lock
.idea
**/*.css.map
.DS_Store
.gitkeep
.gitkeep
.wordpress-org
3 changes: 2 additions & 1 deletion classes/frontend-scripts.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ public static function load_scripts_by_product_id( $product_id, $ppom_id = null,
array(
'jquery',
'ppom-inputs',
)
),
PPOM_VERSION
);

self::set_localize_data( $ppom_conditions_script, 'ppom_input_vars', $product, $input_js_vars, $global_js_vars );
Expand Down
7 changes: 2 additions & 5 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ function ppom_admin_save_form_meta() {
}

$_REQUEST['ppom'] = is_array( $_REQUEST['ppom'] ) ? $_REQUEST['ppom'] : json_decode( wp_unslash( $_REQUEST['ppom'] ), true );

global $wpdb;

extract( $_REQUEST );
Expand Down Expand Up @@ -312,8 +313,6 @@ function( $pm ) {
$aviary_api_key = isset( $_REQUEST['aviary_api_key'] ) ? sanitize_text_field( $_REQUEST['aviary_api_key'] ) : '';
$productmeta_style = isset( $_REQUEST['productmeta_style'] ) ? sanitize_text_field( $_REQUEST['productmeta_style'] ) : '';
$productmeta_js = isset( $_REQUEST['productmeta_js'] ) ? sanitize_text_field( $_REQUEST['productmeta_js'] ) : '';
$productmeta_categories = isset( $_REQUEST['productmeta_categories'] ) ? sanitize_textarea_field( $_REQUEST['productmeta_categories'] ) : '';


if ( strlen( $productmeta_name ) > 50 ) {
$resp = array(
Expand All @@ -330,7 +329,6 @@ function( $pm ) {
'send_file_attachment' => $send_file_attachment,
'show_cart_thumb' => $show_cart_thumb,
'aviary_api_key' => trim( $aviary_api_key ),
'productmeta_categories' => $productmeta_categories,
'the_meta' => $product_meta,
'productmeta_created' => current_time( 'mysql' ),
);
Expand Down Expand Up @@ -453,6 +451,7 @@ function ppom_admin_update_form_meta() {
wp_send_json( $resp );
}
$_REQUEST['ppom'] = is_array( $_REQUEST['ppom'] ) ? $_REQUEST['ppom'] : json_decode( wp_unslash( $_REQUEST['ppom'] ), true );

global $wpdb;

$ppom_meta = isset( $_REQUEST['ppom_meta'] ) ? $_REQUEST['ppom_meta'] : $_REQUEST['ppom'];
Expand All @@ -474,7 +473,6 @@ function( $pm ) {
$aviary_api_key = isset( $_REQUEST['aviary_api_key'] ) ? sanitize_text_field( $_REQUEST['aviary_api_key'] ) : '';
$productmeta_style = isset( $_REQUEST['productmeta_style'] ) ? sanitize_text_field( $_REQUEST['productmeta_style'] ) : '';
$productmeta_js = isset( $_REQUEST['productmeta_js'] ) ? sanitize_text_field( $_REQUEST['productmeta_js'] ) : '';
$productmeta_categories = isset( $_REQUEST['productmeta_categories'] ) ? sanitize_textarea_field( $_REQUEST['productmeta_categories'] ) : '';

if ( strlen( $productmeta_name ) > 50 ) {
$resp = array(
Expand All @@ -491,7 +489,6 @@ function( $pm ) {
'send_file_attachment' => $send_file_attachment,
'show_cart_thumb' => $show_cart_thumb,
'aviary_api_key' => trim( $aviary_api_key ),
'productmeta_categories' => $productmeta_categories,
'the_meta' => $product_meta,
);
if ( ! ppom_is_legacy_user() ) {
Expand Down
10 changes: 8 additions & 2 deletions js/admin/ppom-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ jQuery(function($) {
jQuery(".ppom-meta-save-notice").html('<img src="' + ppom_vars.loader + '">').show();

$('.ppom-unsave-data').remove();
var data = $(this).serializeJSON();
const data = $(this).serializeJSON();

const fieldsOrder = Array(...document.querySelectorAll('.ui-sortable-handle[id^="ppom_sort_id_"]'))
.map( node => node.id.replace('ppom_sort_id_', '') ); // ['2', '3']
data.ppom = fieldsOrder.map( fieldId => data.ppom[fieldId] );

data.ppom = JSON.stringify(data.ppom);

// Send the JSON data via POST request
$.ajax({
url: ajaxurl,
Expand Down Expand Up @@ -329,7 +335,7 @@ jQuery(function($) {
placeholder = '-';
}

var html = '<tr class="row_no_' + id + '" id="ppom_sort_id_' + id + '">';
var html = '<tr class="row_no_' + id + ' ui-sortable-handle" id="ppom_sort_id_' + id + '">';
html += '<td class="ppom-sortable-handle"><i class="fa fa-arrows" aria-hidden="true"></i></td>';
html += '<td class="ppom-check-one-field ppom-checkboxe-style">';
html += '<label>';
Expand Down
10 changes: 4 additions & 6 deletions js/ppom-conditions-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ jQuery(function($) {

const data_name = modifiedElement.dataset?.data_name;
ppom_check_conditions(data_name, (element_dataname, event_type) => {
const event = new CustomEvent(event_type, {
detail: {
field: element_dataname,
time: new Date()
}
$.event.trigger({
type: event_type,
field: element_dataname,
time: new Date()
});
document.dispatchEvent(event);
});
}

Expand Down

0 comments on commit 9ca241d

Please sign in to comment.