kingslayer21
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Glitching Local PickupAny updates on this one?
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,
RolenForum: Plugins
In reply to: [Realtyna Organic IDX plugin + WPL Real Estate] Categorize all the Listingsnevermind, solved it using shortcode wizard.
Forum: Plugins
In reply to: [Realtyna Organic IDX plugin + WPL Real Estate] Google Map Problemalready added an API key, but the problem still persists.
Forum: Plugins
In reply to: [WooCommerce] Checkout Page Add FeeI 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
In reply to: [WooCommerce] Checkout Page Add Feeadd_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
In reply to: [WooCommerce] Woocommerce New Order Email Overridewow, it is now working ! thank you so much Mike. I wonder what’s the difference between variation and variable? 🙂
Forum: Plugins
In reply to: [WooCommerce] Woocommerce New Order Email OverrideI 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
In reply to: [WooCommerce] Woocommerce New Order Email OverrideWhich order email are you checking though?
what do you mean by that Mike?
Forum: Plugins
In reply to: [WooCommerce] Woocommerce New Order Email Overridewp-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
In reply to: [WooCommerce] Woocommerce New Order Email OverrideWhat 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
In reply to: [WooCommerce] Woocommerce New Order Email OverrideTried my code above, and it seems that it does not work. Any other suggestions Mike?
Forum: Plugins
In reply to: [WooCommerce] Woocommerce New Order Email OverrideWhere 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
In reply to: [WooCommerce] Woocommerce New Order Email OverrideActually, 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
In reply to: [Testimonials Widget] Exporting Processhi Subjharanjan, can you please guide me on how to do it? basing on the spreadsheet above? I have importers on my site.
Thanks!