/** * Add customer note via ajax */ function add_customer_note() { $customer_id = (int) $_POST['customer_id']; $note = wp_kses_post(trim(stripslashes($_POST['note']))); if ($customer_id > 0) { $customer = new WC_CRM_Customer($customer_id); $comment_id = $customer->add_note($note); echo '<li rel="' . esc_attr($comment_id) . '" class="note"><div class="note_content">'; echo wpautop(wptexturize($note)); echo '</div><p class="meta"><a href="#" class="delete_customer_note">' . __('Delete note', 'woocommerce') . '</a></p>'; echo '</li>'; } // Quit out die; }
public function get_import_meta_fields() { $customer_detail = new WC_CRM_Customer(); $customer_detail->init_general_fields(); $customer_detail->init_address_fields(); $fields = $customer_detail->general_fields; $billing = $customer_detail->billing_fields; $shipping = $customer_detail->shipping_fields; $keys = array('default' => __('Select fields to map', 'wc_crm'), 'wcrm_custom_meta' => __('Custom meta', 'wc_crm'), 'user_role' => __('Role', 'wc_crm'), 'user_login' => __('User Login', 'wc_crm'), 'user_group' => __('Group', 'wc_crm'), 'user_nicename' => __('Nicename', 'wc_crm'), 'display_name' => __('Display name', 'wc_crm')); if ($fields) { foreach ($fields as $key => $value) { if ($key == 'customer_brands') { continue; } if ($key == 'customer_categories') { continue; } $keys[$value['meta_key']] = $value['label']; } } if ($billing) { foreach ($billing as $key => $value) { $keys['billing_' . $key] = 'Billing ' . $value['label']; } } if ($shipping) { foreach ($shipping as $key => $value) { $keys['shipping_' . $key] = 'Shipping ' . $value['label']; } } return apply_filters('wcrm_get_import_meta_fields', $keys); }
/** * List customer notes (public) * * @access public * @return array */ public function display_notes($customer_id = 0) { ?> <script> jQuery('document').ready(function($){ var parentBody = window.parent.document.body; $('#customer_notes_popup > .media-modal', parentBody).unblock(); }); </script> <style> html{ padding-top: 0 !important; } #wpbody-content{ padding: 0 !important; } #message, #adminmenuwrap, #screen-meta, #screen-meta-links, #adminmenuback, #wpfooter, #wpadminbar{ display: none !important; } #wpcontent{ margin: 0 !important; padding: 0 !important; } #wc-crm-page{ margin: 1.5em !important; } .media-frame-title h1 { text-transform: capitalize; } #wc-crm-page > h2{display: none;} </style> <?php global $the_customer; $the_customer = new WC_CRM_Customer($customer_id); ?> <?php if ($customer_id > 0) { ?> <input type="hidden" id="customer_id" name="customer_id" value="<?php echo $the_customer->customer_id; ?> "> <input type="hidden" id="user_id" name="user_id" value="<?php echo $the_customer->user_id; ?> "> <input type="hidden" id="order_id" name="order_id" value="<?php echo $the_customer->order_id; ?> "> <?php } ?> <div id="side-sortables" class="meta-box-sortables"> <div class="postbox " id="woocommerce-customer-notes"> <div class="inside"> <ul class="order_notes"> <?php $notes = $the_customer->get_customer_notes(); ?> <?php if ($notes) { foreach ($notes as $note) { ?> <li rel="<?php echo absint($note->comment_ID); ?> "> <div class="note_content"> <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> </div> <p class="meta"> <abbr class="exact-date" title="<?php echo $note->comment_date_gmt; ?> GMT"><?php printf(__('added %s ago', 'wc_crm'), human_time_diff(strtotime($note->comment_date_gmt), current_time('timestamp', 1))); ?> </abbr> <?php if ($note->comment_author !== __('WooCommerce', 'wc_crm')) { printf(' ' . __('by %s', 'wc_crm'), $note->comment_author); } ?> <a href="#" class="delete_customer_note"><?php _e('Delete note', 'wc_crm'); ?> </a> </p> </li> <?php } } else { echo '<li>' . __('There are no notes for this customer yet.', 'wc_crm') . '</li>'; } ?> </ul> <div class="add_note"> <h4>Add note</h4> <p> <textarea rows="5" cols="20" class="input-text" id="add_order_note" name="order_note" type="text"></textarea> </p> <p> <a class="add_note_customer button" href="#">Add</a> </p> </div> </div> </div> </div> <?php }
public function select_customer_id() { if (isset($_GET['post_type']) && $_GET['post_type'] == 'shop_order' && isset($_GET['c_id']) && !empty($_GET['c_id'])) { $c_id = $_GET['c_id']; $the_customer = new WC_CRM_Customer($c_id); ob_start(); if ($the_customer->user_id > 0) { $c_name = $the_customer->first_name . ' ' . $the_customer->last_name . ' (#' . $the_customer->user_id . ' - ' . $the_customer->user_email . ')'; ?> jQuery("#customer_user").select2("data", {"id":"<?php echo $the_customer->user_id; ?> ","text":"<?php echo $c_name; ?> "}); <?php } $the_customer->init_address_fields(); $formatted_shipping_address = wp_kses($the_customer->get_formatted_shipping_address(), array("br" => array())); $formatted_billing_address = wp_kses($the_customer->get_formatted_billing_address(), array("br" => array())); $__b_address = $the_customer->billing_fields; $__s_address = $the_customer->shipping_fields; foreach ($__b_address as $key => $field) { $var_name = 'billing_' . $key; ?> jQuery('#_billing_<?php echo $key; ?> ').val( "<?php echo addslashes($the_customer->{$var_name}); ?> " ); <?php } foreach ($__s_address as $key => $field) { $var_name = 'shipping_' . $key; ?> jQuery('#_shipping_<?php echo $key; ?> ').val( "<?php echo addslashes($the_customer->{$var_name}); ?> " ); <?php } ?> jQuery('.order_data_column_container .order_data_column').last().find('.address') .html("<?php echo "<p><strong>" . __("Address", "woocommerce") . ":</strong>" . addslashes($formatted_shipping_address) . "</p>"; ?> "); jQuery('.order_data_column_container .order_data_column').first().next().find('.address') .html("<?php echo "<p><strong>" . __("Address", "woocommerce") . ":</strong>" . addslashes($formatted_billing_address) . "</p>"; ?> "); jQuery('.js_field-country').trigger('change'); <?php $js_string = ob_get_contents(); ob_end_clean(); wc_enqueue_js($js_string); } }