Title: kingslayer21's Replies | WordPress.org

---

# kingslayer21

  [  ](https://wordpress.org/support/users/kingslayer21/)

 *   [Profile](https://wordpress.org/support/users/kingslayer21/)
 *   [Topics Started](https://wordpress.org/support/users/kingslayer21/topics/)
 *   [Replies Created](https://wordpress.org/support/users/kingslayer21/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/kingslayer21/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/kingslayer21/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/kingslayer21/engagements/)
 *   [Favorites](https://wordpress.org/support/users/kingslayer21/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/users/kingslayer21/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/kingslayer21/replies/page/2/?output_format=md)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Glitching Local Pickup](https://wordpress.org/support/topic/glitching-local-pickup/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/glitching-local-pickup/#post-11980649)
 * Any updates on this one?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Go Maps - Google Maps, OpenStreetMap, Leaflet Map] Maps does not show up on front end, but shows up in Admin](https://wordpress.org/support/topic/maps-does-not-show-up-on-front-end-but-shows-up-in-admin/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [8 years, 12 months ago](https://wordpress.org/support/topic/maps-does-not-show-up-on-front-end-but-shows-up-in-admin/#post-9233108)
 * Hi Jarryd!
 * I deleted that line of code and it worked! Never thought the problem would be
   on the CSS. Until now, I don’t understand why it’s affecting the map. haha!
 * Thanks,
    Rolen
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Realtyna Organic IDX plugin + WPL Real Estate] Categorize all the Listings](https://wordpress.org/support/topic/categorize-all-the-listings/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/categorize-all-the-listings/#post-7567820)
 * nevermind, solved it using shortcode wizard.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Realtyna Organic IDX plugin + WPL Real Estate] Google Map Problem](https://wordpress.org/support/topic/google-map-problem-2/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/google-map-problem-2/#post-7564292)
 * already added an API key, but the problem still persists.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Checkout Page Add Fee](https://wordpress.org/support/topic/checkout-page-add-fee/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/checkout-page-add-fee/#post-7450839)
 * I have the whole code below on the checkout page using functions.php, it adds
   the custom fields, what I want is when the user selects a nationality which is
   not Philippines, then there will be additional 2000 for Non Philippines Nationality.
 * My problem is now how to add the 2000 fee.
 *     ```
       function aygt_filter_checkout_fields($fields){
         $numbers = WC()->cart->get_cart_contents_count();
         global $woocommerce;
         $countries_obj   = new WC_Countries();
         $countries   = $countries_obj->__get('countries');
         for ($x = 0; $x <= $numbers - 1; $x++) {
           if ($x == 0) {
           $fields['customerdetails_'.$x] = array(
                   'gender_'.$x => array(
                       'type' => 'select',
                       'options' => array( 'Mr.' => __( 'Mr.' ), 'Ms.' => __( 'Ms.' )),
                       'required'      => true,
                       'label' => __( 'Title' )
                       ),
                   'fname_'.$x => array(
                       'type' => 'text',
                       'required'      => true,
                       'label' => __( 'First Name' )
                       ),
                   'mname_'.$x => array(
                       'type' => 'text',
                       'required'      => true,
                       'label' => __( 'Middle Name' )
                       ),
                   'lname_'.$x => array(
                       'type' => 'text',
                       'required'      => true,
                       'label' => __( 'Last Name' )
                       ),
                   'bday_'.$x => array(
                       'type' => 'text',
                       'required'      => true,
                       'class' => array('bdaypicker'),
                       'label' => __( 'Birthday' )
                       ),
                   'nationality_'.$x => array(
                       'type' => 'select',
                       'required'      => true,
                       'label' => __( 'Nationality' ),
                       'options'    => $countries
                       )
                   );
             } else {
             $fields['customerdetails_'.$x] = array(
                   'gender_'.$x => array(
                       'type' => 'select',
                       'options' => array( 'Mr.' => __( 'Mr.' ), 'Ms.' => __( 'Ms.' )),
                       'required'      => true
                       ),
                   'fname_'.$x => array(
                       'type' => 'text',
                       'required'      => true
                       ),
                   'mname_'.$x => array(
                       'type' => 'text',
                       'required'      => true
                       ),
                   'lname_'.$x => array(
                       'type' => 'text',
                       'required'      => true
                       ),
                   'bday_'.$x => array(
                       'type' => 'text',
                       'required'      => true
                       ),
                   'nationality_'.$x => array(
                       'type' => 'select',
                       'required'      => true,
                       'options'    => $countries
                       )
                   );
             }
           }
   
           return $fields;
       }
       add_filter( 'woocommerce_checkout_fields', 'aygt_filter_checkout_fields' );
   
       // display the extra field on the checkout form
       function aygt_extra_checkout_fields(){ 
   
           $checkout = WC()->checkout(); ?>
   
           <div class="extra-fields">
             <h3><?php _e( 'Customer Details' ); ?></h3>
             <p style = "background-color: #FFE0E0;padding: 15px;border-radius: 5px;text-align:center"><strong style="color:red"><i class="fa fa-exclamation-circle" aria-hidden="true"></i> Important Note:</strong> <strong style="color:#222">To ensure smooth check-in please make sure the guest name is exactly the same as shown in the passport.<br>
             A surcharge of P2000/person for foreign passport holders.</strong></p>
             <?php
             $numbers = WC()->cart->get_cart_contents_count();
             for ($x = 0; $x <= $numbers - 1; $x++) { ?>
               <div class="row">
                   <?php
                   // because of this foreach, everything added to the array in the previous function will display automagically
                   foreach ( $checkout->checkout_fields['customerdetails_'.$x] as $key => $field ) : ?>
                     <?php if ($key == 'gender_'.$x) { ?>
                       <div class="col-md-1 col-xs-12 col-sm-4">
                         <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
                       </div>
                     <?php } else if ($key == 'bday_'.$x) { ?>
                       <div class="bdaypicker col-md-2 col-xs-12 col-sm-4">
                         <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
                       </div>
                     <?php } else if ($key == 'nationality_'.$x) { ?>
                       <div class="nationality col-md-2 col-xs-12 col-sm-4">
                         <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
                       </div>
                     <?php } else { ?>
                       <div class="col-md-2 col-xs-12 col-sm-4">
                         <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
                       </div>
                     <?php } ?>
                   <?php endforeach; ?>
               </div>
             <?php } ?>
           </div>
       <?php }
   
       add_action( 'woocommerce_checkout_after_customer_details' ,'aygt_extra_checkout_fields' );
   
       // save the extra field when checkout is processed
       function aygt_save_extra_checkout_fields( $order_id, $posted ){
           // don't forget appropriate sanitization if you are using a different field type
             $numbers = WC()->cart->get_cart_contents_count();
             for ($x = 0; $x <= $numbers - 1; $x++) {
               if( isset( $posted['gender_'.$x] ) && in_array( $posted['gender_'.$x], array( 'Mr.', 'Ms.' ) ) ) {
                 update_post_meta( $order_id, '_gender_'.$x, $posted['gender_'.$x] );
               }
               if( isset( $posted['fname_'.$x] ) ) {
                 update_post_meta( $order_id, '_fname_'.$x, sanitize_text_field( $posted['fname_'.$x] ) );
               }
               if( isset( $posted['mname_'.$x] ) ) {
                 update_post_meta( $order_id, '_mname_'.$x, sanitize_text_field( $posted['mname_'.$x] ) );
               }
               if( isset( $posted['lname_'.$x] ) ) {
                 update_post_meta( $order_id, '_lname_'.$x, sanitize_text_field( $posted['lname_'.$x] ) );
               }
               if( isset( $posted['bday_'.$x] ) ) {
                 update_post_meta( $order_id, '_bday_'.$x, sanitize_text_field( $posted['bday_'.$x] ) );
               }
               if( isset( $posted['nationality_'.$x] ) ) {
                 update_post_meta( $order_id, '_nationality_'.$x, sanitize_text_field( $posted[ 'nationality_'.$x ] ) );
               }
             }
       }
       add_action( 'woocommerce_checkout_update_order_meta', 'aygt_save_extra_checkout_fields', 10, 2 );
   
       // display the extra data on order recieved page and my-account order review
       function aygt_display_order_data( $order_id ){  ?>
           <h2><?php _e( 'Customer Details' ); ?></h2>
           <table class="table table-hover shop_table shop_table_responsive additional_info">
               <thead>
                 <tr>
                   <th>Title</th>
                   <th>First Name</th>
                   <th>Middle Name</th>
                   <th>Last Name</th>
                   <th>Birthday</th>
                   <th>Nationality</th>
                 </tr>
               </thead>
               <tbody>
                 <?php
                   for ($x = 0; $x <= 49; $x++) {
                     $rowcheck  = get_post_meta( $order_id, '_gender_'.$x, true );
                     if ($rowcheck != "") { ?>
                       <tr>
                        <td> <?php echo get_post_meta( $order_id, '_gender_'.$x, true ); ?> </td>
                        <td> <?php echo get_post_meta( $order_id, '_fname_'.$x, true ); ?> </td>
                        <td> <?php echo get_post_meta( $order_id, '_mname_'.$x, true ); ?> </td>
                        <td> <?php echo get_post_meta( $order_id, '_lname_'.$x, true ); ?> </td>
                        <td> <?php echo get_post_meta( $order_id, '_bday_'.$x, true ); ?> </td>
                        <td> <?php echo WC()->countries->countries[get_post_meta( $order_id, '_nationality_'.$x, true )]; ?> </td>
                       </tr>
                     <?php } else {
                       //
                     }
                   }
                 ?>
               </tbody>
           </table>
       <?php }
       add_action( 'woocommerce_thankyou', 'aygt_display_order_data', 20 );
       add_action( 'woocommerce_view_order', 'aygt_display_order_data', 20 );
   
       // display the extra data in the order admin panel
       function aygt_display_order_data_in_admin( $order ){  ?>
           <?php
             foreach ( $order->get_items() as $item ) {
               $_product = $order->get_product_from_item( $item );
               if ( $_product->is_type( 'variation' ) ) {
                 echo "<h3 style='color:#EF6C00;margin:0;font-weight:bold;'> Promo Package </h3>";
               } else {
                 echo "<h3 style='color:#EF6C00;margin:0;font-weight:bold;'> Regular Package </h3>";
               }
             }
           ?>
           <h4 style="margin-top:0"><?php _e( 'Customer Information' ); ?></h4>
           <table>
               <tbody>
                 <?php
                   for ($x = 0; $x <= 49; $x++) {
                     if (get_post_meta( $order->id, '_gender_'.$x, true ) != "") {
                       echo $x + 1 . ". ";
                       echo get_post_meta( $order->id, '_gender_'.$x, true );
                       echo " ";
                       echo get_post_meta( $order->id, '_fname_'.$x, true );
                       echo " ";
                       echo get_post_meta( $order->id, '_mname_'.$x, true );
                       echo " ";
                       echo get_post_meta( $order->id, '_lname_'.$x, true );
                       echo ", ";
                       echo get_post_meta( $order->id, '_bday_'.$x, true );
                       echo ", ";
                       echo WC()->countries->countries[get_post_meta( $order->id, '_nationality_'.$x, true )];
                       echo "<br>";
                     }
                   }
                 ?>
               </tbody>
           </table>
       <?php }
       add_action( 'woocommerce_admin_order_data_after_order_details', 'aygt_display_order_data_in_admin' );
   
       function aygt_display_email_order_meta( $order, $sent_to_admin, $plain_text ) {
           for ($x = 0; $x <= 49; $x++) {
             $gender[$x] = get_post_meta( $order->id, '_gender_'.$x, true );
             $fname[$x] = get_post_meta( $order->id, '_fname_'.$x, true );
             $mname[$x] = get_post_meta( $order->id, '_mname_'.$x, true );
             $lname[$x] = get_post_meta( $order->id, '_lname_'.$x, true );
             $bday[$x] = get_post_meta( $order->id, '_bday_'.$x, true );
             $nationality[$x] = WC()->countries->countries[get_post_meta( $order->id, '_nationality_'.$x, true )];
           }
           if( $plain_text ){
               echo $another_field;
               echo $some_field;
           } else {
             echo "<h3 style='color: #ef6c00;font-size:18px'>Customer Details</h3>";
             for ($x = 0; $x <= 49; $x++) {
               if ($gender[$x] != "") {
                 echo $x + 1 . ". ";
                 echo $gender[$x];
                 echo " ";
                 echo $fname[$x];
                 echo " ";
                 echo $mname[$x];
                 echo " ";
                 echo $lname[$x];
                 echo ", ";
                 echo $bday[$x];
                 echo ", ";
                 echo $nationality[$x];
                 echo "<br>";
               }
             }
           }
       }
       add_action('woocommerce_email_customer_details', 'aygt_display_email_order_meta', 30, 3 );
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Checkout Page Add Fee](https://wordpress.org/support/topic/checkout-page-add-fee/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/checkout-page-add-fee/#post-7450811)
 *     ```
       add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
       function woocommerce_custom_surcharge() {
         global $woocommerce;
   
       	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
       		return;
   
       	$percentage = 0.01;
       	$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
       	$woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
   
       }
       ```
   
 * Does this even work on the checkout page? Tried this before, then it does not
   even add up on the email of the client.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7421124)
 * wow, it is now working ! thank you so much Mike. I wonder what’s the difference
   between variation and variable? 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7421011)
 * I also edited and I added this block of code on the customer-completed-order.
   php and it works but only outputs the **ELSE** condition. Of course I have been
   testing it on the simple and variable products.
 *     ```
       foreach ( $order->get_items() as $item ) {
            $_product = $order->get_product_from_item( $item );
            if ( $_product->is_type( 'variable' ) ) {
                 _e( "Your order has been received and is now being <b>PROCESSED</b>. Your order details are shown below for your reference:", 'woocommerce' );
            } else {
                 _e( "Your order has been received and is <b>CONFIRMED</b>. Your order details are shown below for your reference:", 'woocommerce' );
            }
       }
       ```
   
 * what could be the problem that I am facing Mike?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7420997)
 * > Which order email are you checking though?
 * what do you mean by that Mike?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7420914)
 * wp-content/plugins/woocommerce/templates/emails/customer-processing-order.php
 * I did put it on the php file above. But it does not change anything on the header.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7420907)
 * What do you mean Mike? I think the order is working on my email template since
   it has the following hook:
 * `do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text,
   $email );`
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7420871)
 * Tried my code above, and it seems that it does not work. Any other suggestions
   Mike?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7420868)
 * Where should I put this Mike?
 * would this work?
 *     ```
       $order->get_items();
   
       foreach ( $order->get_items() as $item ) {
            $_product = $order->get_product_from_item( $item );
            if ( $_product->is_type( 'variable' ) ) {
                 $email_heading= "New Customer Order Confirmed";
            } else {
                 $email_heading= "New Customer Order";
            }
       }
       do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Woocommerce New Order Email Override](https://wordpress.org/support/topic/woocommerce-new-order-email-override/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years ago](https://wordpress.org/support/topic/woocommerce-new-order-email-override/#post-7420865)
 * Actually, I have already modified the woocommerce cart and the customer can only
   buy one product at a time. So there’s no need to loop for checking the items.
   What I need is a conditional code in the email template wherein it checks **if
   the product is variable or simple.**
 * Thanks
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Testimonials Widget] Exporting Process](https://wordpress.org/support/topic/exporting-process/)
 *  Thread Starter [kingslayer21](https://wordpress.org/support/users/kingslayer21/)
 * (@kingslayer21)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/exporting-process/#post-7199164)
 * hi Subjharanjan, can you please guide me on how to do it? basing on the spreadsheet
   above? I have importers on my site.
 * Thanks!

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/users/kingslayer21/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/kingslayer21/replies/page/2/?output_format=md)