Plugin Directory

Changeset 2543843


Ignore:
Timestamp:
06/07/2021 05:51:08 PM (5 years ago)
Author:
emfluencekc
Message:

Plugin version 2.10

Location:
wp-emfluence/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • wp-emfluence/trunk/emfluence.php

    r2533218 r2543843  
    55Description: Easily add forms to your website for contacts to add or update their details in your emfluence Marketing Platform account.
    66Author: emfluence Digital Marketing
    7 Version: 2.9
     7Version: 2.10
    88Author URI: https://www.emfluence.com
    99Text Domain: emfl_form
  • wp-emfluence/trunk/inc/woocommerce.php

    r2533218 r2543843  
    11<?php
     2
     3require_once 'woocommerce.product.meta-field.php';
    24
    35class Emfl_Woocommerce {
     
    3537    }
    3638
    37     $field_id = self::$add_customer_to_group_field_id;
    38     $value = intval(get_post_meta($post->ID, $field_id, TRUE));
    39     if(empty($value)) $value = '';
    40     echo '
    41     <label for="' . esc_attr($field_id) . '">Add the customer to this group</label>
    42     <p><input type="number" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" placeholder="Group ID" value="' . esc_attr($value) . '" /></p>
    43     ';
     39    foreach($this->get_product_meta_fields() as $field) {
     40      $field_id = $field->meta_key;
     41      $value = intval(get_post_meta($post->ID, $field_id, TRUE));
     42      if(empty($value)) $value = '';
     43      echo '
     44      <label for="' . esc_attr($field_id) . '">' . esc_html($field->editor_label) . '</label>
     45      <p><input type="number" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" placeholder="' . esc_attr($field->editor_placeholder) . '" value="' . esc_attr($value) . '" /></p>
     46      ';
     47    }
    4448
    45     $field_id = self::$add_refund_to_group_field_id;
    46     $value = intval(get_post_meta($post->ID, $field_id, TRUE));
    47     echo '
    48     <label for="' . esc_attr($field_id) . '">Add Refunds to this group</label>
    49     <p><input type="number" name="' . esc_attr($field_id) . '" id="' . esc_attr($field_id) . '" placeholder="Group ID" value="' . esc_attr($value) . '" /></p>
    50     ';
    5149  }
    5250
    5351  function save_product_meta_values($post_id) {
    54     foreach([self::$add_refund_to_group_field_id, self::$add_customer_to_group_field_id] as $field_id) {
     52    if('product' !== get_post_type($post_id)) return;
     53    foreach($this->get_product_meta_fields() as $field) {
     54      $field_id = $field->meta_key;
    5555      if(!array_key_exists($field_id, $_POST)) continue; // phpcs:ignore WordPress.Security.NonceVerification.Missing
    5656      $value = intval($_POST[ $field_id ]); // phpcs:ignore WordPress.Security.NonceVerification.Missing
     
    6161      }
    6262    }
     63  }
     64
     65  /**
     66   * @return Emfl_Woocommerce_Product_Meta_Field_Definition[]
     67   */
     68  protected function get_product_meta_fields() {
     69    $fields = [];
     70    $fields[self::$add_customer_to_group_field_id] = new Emfl_Woocommerce_Product_Meta_Field_Definition(
     71        self::$add_customer_to_group_field_id,
     72        'Add the customer to this group',
     73        'Group ID'
     74    );
     75    $fields[self::$add_refund_to_group_field_id] = new Emfl_Woocommerce_Product_Meta_Field_Definition(
     76        self::$add_refund_to_group_field_id,
     77        'Add refunded customers to this group',
     78        'Group ID'
     79    );
     80
     81    /**
     82     * Themes and plugins can extend the fields by filtering this.
     83     */
     84    return apply_filters('emfl_woocommerce_product_meta_fields', $fields);
    6385  }
    6486
     
    99121    );
    100122    if(!empty($company)) $contact['company'] = $company;
     123
     124    $contact = apply_filters('emfl_woocommerce_order_processed_contact_save', $contact, $order, $api);
     125
    101126    $resp = $api->contacts_save($contact);
    102127
     
    132157        'groupIDs' => array_values($platform_list_ids),
    133158    );
     159
     160    $contact = apply_filters('emfl_woocommerce_refund_contact_save', $contact, $order, $api);
     161
    134162    $resp = $api->contacts_save($contact);
    135163
  • wp-emfluence/trunk/readme.txt

    r2533218 r2543843  
    33Requires at least: 4.0
    44Tested up to: 5.7.2
    5 Stable tag: 2.9
     5Stable tag: 2.10
    66Requires PHP: 5.6
    77Contributors: emfluencekc, mightyturtle
     
    5757
    5858== Changelog ==
     59
     60= 2.10 =
     61* Deepen WooCommerce integration to allow add-on product fields
    5962
    6063= 2.9 =
Note: See TracChangeset for help on using the changeset viewer.