Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Add support for a email placeholder {vendor_data} in New vendor notification email to the admin */
- class WCFM_Vendor_Registration_Application_Data {
- private $vendor_id = null;
- public function __construct($member_id) {
- $this->vendor_id = $member_id;
- add_filter('wcfm_email_content_wrapper', array(&$this, 'add_new_email_placeholder_support'), 10, 2);
- }
- public function add_new_email_placeholder_support($message, $email_type) {
- if($this->vendor_id && $email_type == __( 'New Vendor', 'wc-multivendor-membership' )) {
- $member_data = get_userdata( $this->vendor_id );
- $store_name = get_user_meta( $this->vendor_id, 'store_name', true );
- $paymode = get_user_meta( $this->vendor_id, 'wcfm_membership_paymode', true );
- if( $paymode ) {
- $wcfm_membership_payment_methods = get_wcfm_membership_payment_methods();
- if( in_array( $paymode, array( 'paypal_subs', 'paypal_subs_subs' ) ) ) $paymode = 'paypal';
- if( in_array( $paymode, array( 'stripe', 'stripe_subs', 'stripe_subs_subs' ) ) ) $paymode = 'stripe';
- if( in_array( $paymode, array( 'bank_transfer', 'bank_transfer_subs' ) ) ) $paymode = 'bank_transfer';
- if( !$paymode ) $paymode = 'bank_transfer';
- if( isset( $wcfm_membership_payment_methods[$paymode] ) ) {
- $paymode = $wcfm_membership_payment_methods[$paymode];
- } else {
- if ( WC()->payment_gateways() ) {
- $payment_gateways = WC()->payment_gateways->payment_gateways();
- $paymode = isset( $payment_gateways[ $paymode ] ) ? esc_html( $payment_gateways[ $paymode ]->get_title() ) : __( 'FREE', 'wc-multivendor-membership' );
- }
- }
- }
- $wcfmvm_registration_static_fields = wcfm_get_option( 'wcfmvm_registration_static_fields', array() );
- $wcfmvm_static_infos = (array) get_user_meta( $this->vendor_id, 'wcfmvm_static_infos', true );
- $wcfmvm_registration_custom_fields = wcfm_get_option( 'wcfmvm_registration_custom_fields', array() );
- $wcfmvm_custom_infos = (array) get_user_meta( $this->vendor_id, 'wcfmvm_custom_infos', true );
- $store_data_html = '<h2>' . __( 'Application Details', 'wc-multivendor-membership' ) . '</h2>';
- $store_data_html .= '<table width="100%" style="width:100%;">';
- if( isset( $wcfmvm_registration_static_fields['first_name'] ) ) {
- $store_data_html .= '<tr><td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;">' . esc_html( 'First Name', 'wc-multivendor-membership' ) . '</td>';
- $store_data_html .= '<td colspan="5" style="background-color: #f8f8f8;padding: 1em;">' . esc_html($member_data->first_name) . '</td></tr>';
- }
- if( isset( $wcfmvm_registration_static_fields['last_name'] ) ) {
- $store_data_html .= '<tr><td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;">' . esc_html( 'Last Name', 'wc-multivendor-membership' ) . '</td>';
- $store_data_html .= '<td colspan="5" style="background-color: #f8f8f8;padding: 1em;">' . esc_html($member_data->last_name) . '</td></tr>';
- }
- $store_data_html .= '<tr><td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;">' . esc_html( 'User Name', 'wc-multivendor-membership' ) . '</td>';
- $store_data_html .= '<td colspan="5" style="background-color: #f8f8f8;padding: 1em;">' . esc_html($member_data->user_login) . '</td></tr>';
- $store_data_html .= '<tr><td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;">' . esc_html( 'Email', 'wc-multivendor-membership' ) . '</td>';
- $store_data_html .= '<td colspan="5" style="background-color: #f8f8f8;padding: 1em;">' . esc_html($member_data->user_email) . '</td></tr>';
- $store_data_html .= '<tr><td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;">' . esc_html( 'Email', 'wc-multivendor-membership' ) . '</td>';
- $store_data_html .= '<td colspan="5" style="background-color: #f8f8f8;padding: 1em;">' . $store_name . '</td></tr>';
- if( isset( $paymode ) ) {
- $store_data_html .= '<tr><td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;">' . esc_html( 'Pay mode', 'wc-multivendor-membership' ) . '</td>';
- $store_data_html .= '<td colspan="5" style="background-color: #f8f8f8;padding: 1em;">' . wp_kses_post($paymode) . '</td></tr>';
- }
- ob_start();
- if( !empty( $wcfmvm_registration_static_fields ) ) {
- foreach( $wcfmvm_registration_static_fields as $wcfmvm_registration_static_field => $wcfmvm_registration_static_field_val ) {
- $field_value = array();
- $field_name = 'wcfmvm_static_infos[' . $wcfmvm_registration_static_field . ']';
- if( !empty( $wcfmvm_static_infos ) ) {
- $field_value = isset( $wcfmvm_static_infos[$wcfmvm_registration_static_field] ) ? $wcfmvm_static_infos[$wcfmvm_registration_static_field] : array();
- }
- switch( $wcfmvm_registration_static_field ) {
- case 'address':
- if( isset($field_value['addr_1']) ) {
- $state_code = $field_value['state'];
- $country_code = $field_value['country'];
- $state = isset( WC()->countries->states[ $country_code ][ $state_code ] ) ? WC()->countries->states[ $country_code ][ $state_code ] : $state_code;
- $country = isset( WC()->countries->countries[ $country_code ] ) ? WC()->countries->countries[ $country_code ] : $country_code;
- $address = $field_value['addr_1'] . ' ' . $field_value['addr_2']. '<br/>' . $field_value['city']. ', ' . $state. '<br />' . $field_value['zip']. '<br />' . $country;
- ?>
- <tr>
- <td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;"><?php esc_html_e( 'Store Address', 'wc-frontend-manager' ); ?></td>
- <td colspan="5" style="background-color: #f8f8f8;padding: 1em;"><?php echo wp_kses_post($address); ?></td>
- </tr>
- <?php
- }
- break;
- case 'phone':
- ?>
- <tr>
- <td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;"><?php esc_html_e( 'Store Phone', 'wc-frontend-manager' ); ?></td>
- <td colspan="5" style="background-color: #f8f8f8;padding: 1em;"><?php echo wp_kses_post($field_value); ?></td>
- </tr>
- <?php
- break;
- default:
- do_action( 'wcfmvm_registration_static_field_popup_show', $this->vendor_id, $wcfmvm_registration_static_field, $field_value );
- break;
- }
- }
- }
- if( !empty( $wcfmvm_registration_custom_fields ) ) {
- foreach( $wcfmvm_registration_custom_fields as $wcfmvm_registration_custom_field ) {
- if( !isset( $wcfmvm_registration_custom_field['enable'] ) ) continue;
- if( !$wcfmvm_registration_custom_field['label'] ) continue;
- $field_value = '';
- $wcfmvm_registration_custom_field['name'] = sanitize_title( $wcfmvm_registration_custom_field['label'] );
- if( !empty( $wcfmvm_custom_infos ) ) {
- if( $wcfmvm_registration_custom_field['type'] == 'checkbox' ) {
- $field_value = isset( $wcfmvm_custom_infos[$wcfmvm_registration_custom_field['name']] ) ? $wcfmvm_custom_infos[$wcfmvm_registration_custom_field['name']] : 'no';
- } elseif( $wcfmvm_registration_custom_field['type'] == 'upload' ) {
- $field_name = 'wcfmvm_custom_infos[' . $wcfmvm_registration_custom_field['name'] . ']';
- $field_id = md5( $field_name );
- $field_value = isset( $wcfmvm_custom_infos[$field_id] ) ? $wcfmvm_custom_infos[$field_id] : '';
- } else {
- $field_value = isset( $wcfmvm_custom_infos[$wcfmvm_registration_custom_field['name']] ) ? $wcfmvm_custom_infos[$wcfmvm_registration_custom_field['name']] : '';
- }
- }
- ?>
- <tr>
- <td colspan="3" style="background-color: #eeeeee;padding: 1em 1.41575em;line-height: 1.5;"><?php esc_html_e( $wcfmvm_registration_custom_field['label'], 'WCfM'); ?></td>
- <td colspan="5" style="background-color: #f8f8f8;padding: 1em;">
- <?php
- if( $field_value && $wcfmvm_registration_custom_field['type'] == 'upload' ) {
- echo '<a class="wcfm-wp-fields-uploader" target="_blank" style="width: 32px; height: 32px;" href="' . esc_url(wcfm_get_attachment_url( $field_value )) . '">Upload</a>';
- } else {
- if( !$field_value ) $field_value = '–';
- if( is_array( $field_value ) ) echo wp_kses_post(implode( ', ', $field_value ));
- else echo wp_kses_post($field_value);
- }
- ?>
- </td>
- </tr>
- <?php
- }
- }
- $store_data_html .= ob_get_clean();
- $store_data_html .= '</table><br />';
- $message = str_replace( '{vendor_data}', $store_data_html, $message );
- }
- return $message;
- }
- }
- add_action( 'wcfmmp_new_store_created', function($store_id) {
- new WCFM_Vendor_Registration_Application_Data($store_id);
- }, 12 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement