Showing with 45 additions and 30 deletions.
  1. +6 −0 CHANGELOG.md
  2. +26 −26 js/ppom-conditions-v2.js
  3. +1 −1 package.json
  4. +10 −1 readme.txt
  5. +2 −2 woocommerce-product-addon.php
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
##### [Version 32.0.13](https://github.com/Codeinwp/woocommerce-product-addon/compare/v32.0.12...v32.0.13) (2024-03-07)

### Bug Fixes
- Conditional fields not displaying in the cart
- Predefined values not working with conditions

##### [Version 32.0.12](https://github.com/Codeinwp/woocommerce-product-addon/compare/v32.0.11...v32.0.12) (2024-03-01)

### Fixes
Expand Down
52 changes: 26 additions & 26 deletions js/ppom-conditions-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jQuery(function($) {
});
});
});

$('form.cart').find('div.ppom-c-hide').each(function(i, field) {
const data_name = $(field).data('data_name');
$.event.trigger({
Expand Down Expand Up @@ -84,7 +84,7 @@ jQuery(function($) {


$(document).on('ppom_field_hidden', function(e) {

// console.log(e.field)

var element_type = ppom_get_field_type_by_id(e.field);
Expand Down Expand Up @@ -118,7 +118,7 @@ jQuery(function($) {
case 'checkbox':
$('input[name="ppom[fields][' + e.field + '][]"]').prop('checked', false);
break;

case 'radio':
$('input[name="ppom[fields][' + e.field + ']"]').prop('checked', false);
break;
Expand Down Expand Up @@ -146,11 +146,11 @@ jQuery(function($) {
case 'pricematrix':
$(`input[data-dataname="ppom[fields][${e.field}]"]`).removeClass('active');
break;

case 'quantities':
$(`input[name^="ppom[fields][${e.field}]"]`).val('');
break;

case 'fixedprice':
// if select type is radio
$('input[name="ppom[fields][' + e.field + ']"]').prop('checked', false);
Expand Down Expand Up @@ -190,7 +190,7 @@ jQuery(function($) {
$(document).on('ppom_field_shown', function(e) {

ppom_fields_hidden_conditionally();

// Set checked/selected again
ppom_set_default_option(e.field);

Expand Down Expand Up @@ -279,7 +279,7 @@ function ppom_check_conditions(data_name, callback) {
// const field_val = ppom_get_element_value(data_name);
// console.log('data_name',data_name);
jQuery(`div.ppom-cond-${data_name}`).each(function() {
// return this.data('cond-val1').match(/\w*-Back/);
// return this.data('cond-val1').match(/\w*-Back/);
// console.log(jQuery(this));
const total_cond = parseInt(jQuery(this).data('cond-total'));
const binding = jQuery(this).data(`cond-bind`);
Expand Down Expand Up @@ -308,14 +308,14 @@ function ppom_check_conditions(data_name, callback) {
}

matched_conditions[element_data_name] = matched;

event_type = visibility === 'hide' ? 'ppom_field_hidden' : 'ppom_field_shown';
// console.log(`${t} ***** ${element_data_name} total_cond ${total_cond} == matched ${matched} ==> ${matched_conditions[element_data_name]} ==> visibility ${event_type}`);

if ( (matched_conditions[element_data_name] > 0 && binding === 'Any') ||
(matched_conditions[element_data_name] == total_cond && binding === 'All')
) {

// remove/add locked classes for all dependent fields
cond_elements.forEach(cond_dataname => {
if( visibility === 'hide' ){
Expand All @@ -325,27 +325,27 @@ function ppom_check_conditions(data_name, callback) {
}
});

if (typeof callback == "function" && 'undefined' !== typeof ppom_type)
if (typeof callback == "function")
callback(element_data_name, event_type);
// return is_matched;
}
else if ( ! is_matched || matched_conditions[element_data_name] !== total_cond) {

if( visibility === 'hide' ){
event_type = 'ppom_field_shown';
jQuery(this).removeClass(`ppom-locked-${data_name} ppom-c-hide`);
jQuery(this).removeClass(`ppom-locked-${data_name} ppom-c-hide`);
}else{
event_type = 'ppom_field_hidden';
jQuery(this).addClass(`ppom-locked-${data_name} ppom-c-hide`);
}

if (typeof callback == "function" && 'undefined' !== typeof ppom_type)
if (typeof callback == "function")
callback(element_data_name, event_type);
} else {

jQuery(this).removeClass(`ppom-locked-${data_name} ppom-c-hide`);
// console.log('event_type', event_type);
if (typeof callback == "function" && 'undefined' !== typeof ppom_type)
if (typeof callback == "function")
callback(element_data_name, event_type);
}
}
Expand All @@ -368,7 +368,7 @@ function ppom_get_element_value(data_name) {
const ppom_type = ppom_get_input_dom_type(data_name);
let element_value = '';
var value_found_cb = [];

switch (ppom_type) {
case 'switcher':
case 'radio':
Expand Down Expand Up @@ -398,7 +398,7 @@ function ppom_get_element_value(data_name) {
default:
element_value = jQuery(`.ppom-input[data-data_name="${data_name}"]`).val();
}

if (ppom_type === 'checkbox' || ppom_type === 'palettes') {
// console.log(value_found_cb);
return value_found_cb;
Expand Down Expand Up @@ -438,15 +438,15 @@ function ppom_compare_values(v1, v2, operator) {
}

function ppom_set_default_option(field_id) {

// get product id
var product_id = ppom_input_vars.product_id;

var field = ppom_get_field_meta_by_id(field_id);

switch (field.type) {

// Check if field is
// Check if field is
case 'switcher':
case 'radio':
jQuery.each(field.options, function(label, options) {
Expand Down Expand Up @@ -485,14 +485,14 @@ function ppom_set_default_option(field_id) {
}
});
break;

case 'quantities':
jQuery.each(field.options, function(label, options) {
//console.log(options);
if( options.default === '' ) return;
var opt_id = product_id + '-' + field.data_name + '-' + options.id;
jQuery("#" + opt_id).val(options.default).trigger('change');

});
break;

Expand All @@ -509,7 +509,7 @@ function ppom_set_default_option(field_id) {
// Updating conditionally hidden fields
function ppom_fields_hidden_conditionally() {

// Reset
// Reset
ppom_hidden_fields = [];
// jQuery(`.ppom-field-wrapper.ppom-c-hide`).filter(function() {

Expand All @@ -520,8 +520,8 @@ function ppom_fields_hidden_conditionally() {
// });
// console.log("Condionally Hidden", ppom_hidden_fields);
// jQuery("#conditionally_hidden").val(ppom_hidden_fields);
var datanames = jQuery(`.ppom-field-wrapper[class*="ppom-locked-"]`).map( (i,h) => ppom_hidden_fields.push(jQuery(h).data('data_name')) );

var datanames = jQuery(`.ppom-field-wrapper[class*="ppom-locked-"]`).map( (i,h) => ppom_hidden_fields.push(jQuery(h).data('data_name')) );
jQuery("#conditionally_hidden").val(ppom_hidden_fields);
// console.log(ppom_hidden_fields);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woocommerce-product-addon",
"version": "32.0.12",
"version": "32.0.13",
"description": "PPOM for WooCommerce",
"main": "index.js",
"repository": "https://github.com/Codeinwp/woocommerce-product-addon",
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: themeisle
Tags: woocommerce product addons, woocommerce product options, woocommerce product fields, woocommerce product, woocommerce product addon
Requires at least: 3.5
Tested up to: 6.4
Stable tag: 32.0.12
Stable tag: 32.0.13
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Requires PHP: 7.2
Expand Down Expand Up @@ -122,6 +122,15 @@ If you feels that PPOM Free or PPOM PRO versions are not enough for your needs,

== Changelog ==

##### [Version 32.0.13](https://github.com/Codeinwp/woocommerce-product-addon/compare/v32.0.12...v32.0.13) (2024-03-07)

### Bug Fixes
- Conditional fields not displaying in the cart
- Predefined values not working with conditions




##### [Version 32.0.12](https://github.com/Codeinwp/woocommerce-product-addon/compare/v32.0.11...v32.0.12) (2024-03-01)

### Fixes
Expand Down
4 changes: 2 additions & 2 deletions woocommerce-product-addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: PPOM for WooCommerce
* Plugin URI: https://themeisle.com/plugins/ppom-pro/
* Description: PPOM (Personalized Product Meta Manager) plugin allow WooCommerce Store Admin to create unlimited input fields and files to attach with Product Pages.
* Version: 32.0.12
* Version: 32.0.13
* Author: Themeisle
* Text Domain: woocommerce-product-addon
* Domain Path: /languages
Expand All @@ -26,7 +26,7 @@
define( 'PPOM_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'PPOM_WP_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __DIR__ ) ) );
define( 'PPOM_BASENAME', basename( PPOM_WP_PLUGIN_DIR ) );
define( 'PPOM_VERSION', '32.0.12' );
define( 'PPOM_VERSION', '32.0.13' );
define( 'PPOM_DB_VERSION', '30.1.0' );
define( 'PPOM_PRODUCT_META_KEY', '_product_meta_id' );
define( 'PPOM_TABLE_META', 'nm_personalized' );
Expand Down