Changeset 2543843
- Timestamp:
- 06/07/2021 05:51:08 PM (5 years ago)
- Location:
- wp-emfluence/trunk
- Files:
-
- 1 added
- 3 edited
-
emfluence.php (modified) (1 diff)
-
inc/woocommerce.php (modified) (5 diffs)
-
inc/woocommerce.product.meta-field.php (added)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-emfluence/trunk/emfluence.php
r2533218 r2543843 5 5 Description: Easily add forms to your website for contacts to add or update their details in your emfluence Marketing Platform account. 6 6 Author: emfluence Digital Marketing 7 Version: 2. 97 Version: 2.10 8 8 Author URI: https://www.emfluence.com 9 9 Text Domain: emfl_form -
wp-emfluence/trunk/inc/woocommerce.php
r2533218 r2543843 1 1 <?php 2 3 require_once 'woocommerce.product.meta-field.php'; 2 4 3 5 class Emfl_Woocommerce { … … 35 37 } 36 38 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 } 44 48 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 ';51 49 } 52 50 53 51 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; 55 55 if(!array_key_exists($field_id, $_POST)) continue; // phpcs:ignore WordPress.Security.NonceVerification.Missing 56 56 $value = intval($_POST[ $field_id ]); // phpcs:ignore WordPress.Security.NonceVerification.Missing … … 61 61 } 62 62 } 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); 63 85 } 64 86 … … 99 121 ); 100 122 if(!empty($company)) $contact['company'] = $company; 123 124 $contact = apply_filters('emfl_woocommerce_order_processed_contact_save', $contact, $order, $api); 125 101 126 $resp = $api->contacts_save($contact); 102 127 … … 132 157 'groupIDs' => array_values($platform_list_ids), 133 158 ); 159 160 $contact = apply_filters('emfl_woocommerce_refund_contact_save', $contact, $order, $api); 161 134 162 $resp = $api->contacts_save($contact); 135 163 -
wp-emfluence/trunk/readme.txt
r2533218 r2543843 3 3 Requires at least: 4.0 4 4 Tested up to: 5.7.2 5 Stable tag: 2. 95 Stable tag: 2.10 6 6 Requires PHP: 5.6 7 7 Contributors: emfluencekc, mightyturtle … … 57 57 58 58 == Changelog == 59 60 = 2.10 = 61 * Deepen WooCommerce integration to allow add-on product fields 59 62 60 63 = 2.9 =
Note: See TracChangeset
for help on using the changeset viewer.