WCFM – Variable Products with Quotes in the Attribute names

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Best Multi Vendor Marketplace Plugin for WordPress Forums WCFM WCFM – Variable Products with Quotes in the Attribute names

Viewing 3 reply threads
  • Author
    Posts
    • #44417
      ouija
      Guest

      Hi,

      I just wanted to report a bug with WCFM and the front-end product manager not properly selecting the variation / attribute names when the name has a quote (“) in the name and viewing the list of variations on the front end.

      This is likely due to the quote in the attribute name causing the javascript to fail because it isn’t being escaped, and thereby prevents the front end from selecting that variation name. This is also affecting the ‘default selections’ of variations, again, if the variation attribute has a quote in it.

      I’ll try and resolve this issue myself and post back with my solution if/when I do.

      Example:

      <script async src=”//s.imgur.com/min/embed.js” charset=”utf-8″></script>

      Thank you.

    • #44418
      ouija
      Guest

      Sorry, here’s an example of a variable product where one of the attributes has quotes in the names (for different sizes of pizza):

      https://imgur.com/a/5QxZsN6

      and here’s how it SHOULD load the product by default:

      https://imgur.com/a/XoY7Lbu

      Hope this better illustrates the issue I’m describing.

    • #44419
      ouija
      Guest

      I managed to resolve this for my needs by editing the /wp-content/plugins/wc-frontend-manager/core/class-wcfm-ajax.php file and modified the wcfm_generate_variation_attributes() function, by replacing all occurances of esc_attr within this function to use addslashes instead.

      Here’s how the function looks now:

      global $wpdb, $WCFM;

      $wcfm_products_manage_form_data = array();
      parse_str($_POST[‘wcfm_products_manage_form’], $wcfm_products_manage_form_data);
      //print_r($wcfm_products_manage_form_data);

      if(isset($wcfm_products_manage_form_data[‘attributes’]) && !empty($wcfm_products_manage_form_data[‘attributes’])) {
      $pro_attributes = ‘{‘;
      $attr_first = true;
      foreach($wcfm_products_manage_form_data[‘attributes’] as $attributes) {
      if(isset($attributes[‘is_variation’])) {
      if( isset( $attributes[‘is_active’] ) && !empty( $attributes[‘name’] ) && !empty( $attributes[‘value’] ) ) {
      if(!$attr_first) $pro_attributes .= ‘,’;
      if($attr_first) $attr_first = false;

      if($attributes[‘is_taxonomy’]) {
      $pro_attributes .= ‘”‘ . sanitize_title( $attributes[‘tax_name’] ) . ‘”: { “name” : ” ‘ . $attributes[‘name’] . ‘ “, “data” : {‘;
      if( !is_array($attributes[‘value’]) ) {
      $att_values = explode( WC_DELIMITER , $attributes[‘value’]);
      $is_first = true;
      foreach($att_values as $att_value) {
      if(!$is_first) $pro_attributes .= ‘,’;
      if($is_first) $is_first = false;
      $pro_attributes .= ‘”‘ . sanitize_title($att_value) . ‘”: “‘ . addslashes(trim($att_value)) . ‘”‘;
      }
      } else {
      $att_values = $attributes[‘value’];
      $is_first = true;
      foreach($att_values as $att_value) {
      if(!$is_first) $pro_attributes .= ‘,’;
      if($is_first) $is_first = false;
      $att_term = get_term( absint($att_value) );
      if( $att_term ) {
      $pro_attributes .= ‘”‘ . $att_term->slug . ‘”: “‘ . addslashes($att_term->name) . ‘”‘;
      } else {
      $pro_attributes .= ‘”‘ . sanitize_title($att_value) . ‘”: “‘ . addslashes(trim($att_value)) . ‘”‘;
      }
      }
      }
      $pro_attributes .= ‘} }’;
      } else {
      $pro_attributes .= ‘”‘ . sanitize_title( $attributes[‘name’] ) . ‘”: { “name” : ” ‘ . $attributes[‘name’] . ‘ “, “data” : {‘;
      $att_values = explode( WC_DELIMITER, $attributes[‘value’]);
      $is_first = true;
      foreach($att_values as $att_value) {
      if(!$is_first) $pro_attributes .= ‘,’;
      if($is_first) $is_first = false;
      $pro_attributes .= ‘”‘ . addslashes(trim($att_value)) . ‘”: “‘ . addslashes(trim($att_value)) . ‘”‘;
      }
      $pro_attributes .= ‘} }’;
      }
      }
      }
      }
      $pro_attributes .= ‘}’;
      echo $pro_attributes;
      }

      die();
      }

    • #44448
      WCFM Forum
      Member

      Hi,

      Thanks for the all details.

      We understand this issue, we will take care of this in next update.

      Well, you have tried well, but this will not resolve this fully. On edit, it will cause problem.

      Thank You

Viewing 3 reply threads
  • The topic ‘WCFM – Variable Products with Quotes in the Attribute names’ is closed to new replies.