Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mamatharao05 committed Feb 2, 2024
1 parent 93b3af5 commit eac0302
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions includes/ECommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ public function update_text( $translated_text, $text, $domain ) {
return $translated_text;
}

/**
* Add phone number and Email field to WooCommerce shipping form
*/
public function add_phone_number_email_to_shipping_form($fields) {
$fields['shipping_phone'] = array(
'label' => __('Phone Number', 'woocommerce'),
Expand All @@ -385,7 +388,9 @@ public function add_phone_number_email_to_shipping_form($fields) {
return $fields;
}


/**
* Display phone number and Email field on the shipping form
*/
public function display_custom_shipping_fields($method, $index) {
echo '<div class="shipping-phone">';
woocommerce_form_field('shipping_phone', array(
Expand All @@ -408,7 +413,9 @@ public function display_custom_shipping_fields($method, $index) {
echo '</div>';
}


/**
* Save phone number and email fields to order meta
*/
function save_custom_shipping_fields($order) {
$shipping_phone = isset($_POST['shipping_phone']) ? sanitize_text_field($_POST['shipping_phone']) : '';
$shipping_email = isset($_POST['shipping_email']) ? sanitize_email($_POST['shipping_email']) : '';
Expand All @@ -422,6 +429,9 @@ function save_custom_shipping_fields($order) {
}
}

/**
* Display phone number and email fields in order admin
*/
public function display_custom_shipping_fields_in_admin($order) {
$shipping_phone = $order->get_meta('_shipping_phone');
$shipping_email = $order->get_meta('_shipping_email');
Expand Down

0 comments on commit eac0302

Please sign in to comment.