Switch fields order in Easy Digital Downloads checkout - php

I'd like to switch the order of the 'Billing City' and the 'Billing ZIP' field in the code below through a snippet in my functions.php file. I've been on it for hours, but I can't get it right. This is the code in the easy-digital-downloads/includes/checkout/template.php file, thank you so much for helping out:
<?php
do_action( 'edd_after_cc_fields' );
echo ob_get_clean();
}
add_action( 'edd_cc_form', 'edd_get_cc_form' );
/**
* Outputs the default credit card address fields
*
* #since 1.0
* #return void
*/
function edd_default_cc_address_fields() {
$logged_in = is_user_logged_in();
$customer = EDD()->session->get( 'customer' );
$customer = wp_parse_args( $customer, array( 'address' => array(
'line1' => '',
'line2' => '',
'city' => '',
'zip' => '',
'state' => '',
'country' => ''
) ) );
$customer['address'] = array_map( 'sanitize_text_field', $customer['address'] );
if( $logged_in ) {
$user_address = get_user_meta( get_current_user_id(), '_edd_user_address', true );
foreach( $customer['address'] as $key => $field ) {
if ( empty( $field ) && ! empty( $user_address[ $key ] ) ) {
$customer['address'][ $key ] = $user_address[ $key ];
} else {
$customer['address'][ $key ] = '';
}
}
}
/**
* Billing Address Details.
*
* Allows filtering the customer address details that will be pre-populated on the checkout form.
*
* #since 2.8
*
* #param array $address The customer address.
* #param array $customer The customer data from the session
*/
$customer['address'] = apply_filters( 'edd_checkout_billing_details_address', $customer['address'], $customer );
ob_start(); ?>
<fieldset id="edd_cc_address" class="cc-address">
<legend><?php _e( 'Billing Details', 'easy-digital-downloads' ); ?></legend>
<?php do_action( 'edd_cc_billing_top' ); ?>
<p id="edd-card-address-wrap">
<label for="card_address" class="edd-label">
<?php _e( 'Billing Address', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_address' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The primary billing address for your credit card.', 'easy-digital-downloads' ); ?></span>
<input type="text" id="card_address" name="card_address" class="card-address edd-input<?php if( edd_field_is_required( 'card_address' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'Address line 1', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['line1']; ?>"<?php if( edd_field_is_required( 'card_address' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-address-2-wrap">
<label for="card_address_2" class="edd-label">
<?php _e( 'Billing Address Line 2 (optional)', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_address_2' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The suite, apt no, PO box, etc, associated with your billing address.', 'easy-digital-downloads' ); ?></span>
<input type="text" id="card_address_2" name="card_address_2" class="card-address-2 edd-input<?php if( edd_field_is_required( 'card_address_2' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'Address line 2', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['line2']; ?>"<?php if( edd_field_is_required( 'card_address_2' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-city-wrap">
<label for="card_city" class="edd-label">
<?php _e( 'Billing City', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_city' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The city for your billing address.', 'easy-digital-downloads' ); ?></span>
<input type="text" id="card_city" name="card_city" class="card-city edd-input<?php if( edd_field_is_required( 'card_city' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'City', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['city']; ?>"<?php if( edd_field_is_required( 'card_city' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-zip-wrap">
<label for="card_zip" class="edd-label">
<?php _e( 'Billing Zip / Postal Code', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_zip' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The zip or postal code for your billing address.', 'easy-digital-downloads' ); ?></span>
<input type="text" size="4" id="card_zip" name="card_zip" class="card-zip edd-input<?php if( edd_field_is_required( 'card_zip' ) ) { echo ' required'; } ?>" placeholder="<?php _e( 'Zip / Postal Code', 'easy-digital-downloads' ); ?>" value="<?php echo $customer['address']['zip']; ?>"<?php if( edd_field_is_required( 'card_zip' ) ) { echo ' required '; } ?>/>
</p>
<p id="edd-card-country-wrap">
<label for="billing_country" class="edd-label">
<?php _e( 'Billing Country', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'billing_country' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The country for your billing address.', 'easy-digital-downloads' ); ?></span>
<select name="billing_country" id="billing_country" data-nonce="<?php echo wp_create_nonce( 'edd-country-field-nonce' ); ?>" class="billing_country edd-select<?php if( edd_field_is_required( 'billing_country' ) ) { echo ' required'; } ?>"<?php if( edd_field_is_required( 'billing_country' ) ) { echo ' required '; } ?>>
<?php
$selected_country = edd_get_shop_country();
if( ! empty( $customer['address']['country'] ) && '*' !== $customer['address']['country'] ) {
$selected_country = $customer['address']['country'];
}
$countries = edd_get_country_list();
foreach( $countries as $country_code => $country ) {
echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
}
?>
</select>
</p>
<p id="edd-card-state-wrap">
<label for="card_state" class="edd-label">
<?php _e( 'Billing State / Province', 'easy-digital-downloads' ); ?>
<?php if( edd_field_is_required( 'card_state' ) ) { ?>
<span class="edd-required-indicator">*</span>
<?php } ?>
</label>
<span class="edd-description"><?php _e( 'The state or province for your billing address.', 'easy-digital-downloads' ); ?></span>
<?php
$selected_state = edd_get_shop_state();
$states = edd_get_shop_states( $selected_country );
if( ! empty( $customer['address']['state'] ) ) {
$selected_state = $customer['address']['state'];
}
if( ! empty( $states ) ) : ?>
<select name="card_state" id="card_state" class="card_state edd-select<?php if( edd_field_is_required( 'card_state' ) ) { echo ' required'; } ?>">
<?php
foreach( $states as $state_code => $state ) {
echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
}
?>
</select>
<?php else : ?>
<?php $customer_state = ! empty( $customer['address']['state'] ) ? $customer['address']['state'] : ''; ?>
<input type="text" size="6" name="card_state" id="card_state" class="card_state edd-input" value="<?php echo esc_attr( $customer_state ); ?>" placeholder="<?php _e( 'State / Province', 'easy-digital-downloads' ); ?>"/>
<?php endif; ?>
</p>
<?php do_action( 'edd_cc_billing_bottom' ); ?>
<?php wp_nonce_field( 'edd-checkout-address-fields', 'edd-checkout-address-fields-nonce', false, true ); ?>
</fieldset>
<?php
echo ob_get_clean();
}
add_action( 'edd_after_cc_fields', 'edd_default_cc_address_fields' );

Ok, based on your comments i would say the EASIEST (not the cleanest) way to achieve that is to include a small piece of JS to move the DIV
$("#edd-card-zip-wrap").insertBefore("#edd-card-city-wrap");
That should be enought :)
Edit:
Paste this code into your theme's functions.php
add_action( 'wp_enqueue_scripts', 'enqueue_my_script' );
function enqueue_my_script() {
wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/my-script.js', array( "jquery" ), false, true );
}
This will search for a file named "my-script.js" that lives in the root folder of your theme (same level as the functions.php file)
That file content can be something like this:
Edited with fixed wait:
$("document").ready(function() {
var waitThisTime = 1000; // Wait this ms. 1000ms = 1sec
setTimeout(function(){
$("#edd-card-zip-wrap").insertBefore("#edd-card-city-wrap");
},waitThisTime);
});

You can do that by using below code snippet.
add_filter( 'woocommerce_checkout_fields', 'ro_postcode_city_interchange' );
function ro_postcode_city_interchange( $checkout_fields ) {
$checkout_fields['billing']['billing_postcode']['priority'] = 70;
$checkout_fields['billing']['billing_city']['priority'] = 90;
return $checkout_fields;
}
This code snipper will interchange the order as all fields have their priority so here you have to give postcode priority of city and city priority of zipcode.
Tested and works well.

Related

Combine two forms from different plugins in Wordpress

I want to combine two forms from two different plugins namely : Wp job manager (Plugin A) and Afj Company Listings (plugin B). plugin A has a form called job-submit.php (located in: public_html/wp-content/plugins/wp-job-manager/templates) which would like to combine with another form from Plugin B called company_listings-submit.php (located in: public_html/wp-content/plugins/afj-company-listings/templates).
What I have done is to add get method in the job-submit.php but didnt work:
get_afj_company_listings_template( 'company_listings-submit.php' )
job-submit.php
/**
Content for job submission ([submit_job_form]) shortcode.
This template can be overridden by copying it to yourtheme/job_manager/job-submit.php.
#see https://wpjobmanager.com/document/template-overrides/
#author Automattic
#package wp-job-manager
#category Template
#version 1.34.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
global $job_manager;
?>
" method="post" id="submit-job-form" class="job-manager-form" enctype="multipart/form-data">
<?php
if ( isset( $resume_edit ) && $resume_edit ) {
printf( '<p><strong>' . esc_html__( "You are editing an existing job. %s", 'wp-job-manager' ) . '</strong></p>', '' . esc_html__( 'Create A New Job', 'wp-job-manager' ) . '' );
}
?>
<?php do_action( 'submit_job_form_start' ); ?>
<?php if ( apply_filters( 'submit_job_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php' ); ?>
<?php endif; ?>
<?php if ( job_manager_user_can_post_job() || job_manager_user_can_edit_job( $job_id ) ) : ?>
<!-- Job Information Fields -->
<?php do_action( 'submit_job_form_job_fields_start' ); ?>
<!-- MY OWN CODE HERE-----afj-company-listings/templates/company_listings-submit.php wp-content/plugins/wp-job-manager/templates-->
<?php get_job_manager_template( 'company_listings-submit.php' ); ?>
<?php foreach ( $job_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php echo esc_attr( $key ); ?> fieldset-type-<?php echo esc_attr( $field['type'] ); ?>">
<label for="<?php echo esc_attr( $key ); ?>"><?php echo wp_kses_post(
$field['label'] ) . wp_kses_post( apply_filters( 'submit_job_form_required_label',
$field['required'] ? '' : ' ' . __( '(optional)', 'wp-job-manager' ) . '', $field )
); ?>
">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-
field.php', [ 'key' => $key, 'field' => $field ] ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_job_fields_end' ); ?>
<!-- Company Information Fields -->
<?php if ( $company_fields ) : ?>
<h2><?php esc_html_e( 'Company Details', 'wp-job-manager' ); ?></h2>
<?php do_action( 'submit_job_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php echo esc_attr( $key ); ?> fieldset-type-<?php echo esc_attr( $field['type'] ); ?>">
<label for="<?php echo esc_attr( $key ); ?>"><?php echo wp_kses_post(
$field['label'] ) . wp_kses_post( apply_filters( 'submit_job_form_required_label',
$field['required'] ? '' : ' ' . __( '(optional)', 'wp-job-manager' ) . '', $field ) ); ?>
">
<?php get_job_manager_template( 'form-fields/' . $field['type'] . '-field.php', [ 'key' => $key, 'field' => $field ] ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_job_form_company_fields_end' ); ?>
<?php endif; ?>
<?php do_action( 'submit_job_form_end' ); ?>
<p>
<input type="hidden" name="job_manager_form" value="<?php echo esc_attr( $form ); ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_job" class="button" value="<?php echo esc_attr(
$submit_button_text ); ?>" />
<?php
if ( isset( $can_continue_later ) && $can_continue_later ) {
echo '<input type="submit" name="save_draft" class="button secondary save_draft"
value="' . esc_attr__( 'Save Draft', 'wp-job-manager' ) . '" formnovalidate />';
}
?>
<span class="spinner" style="background-image: url(<?php echo esc_url( includes_url(
'images/spinner.gif' ) ); ?>);">
</p>
<?php else : ?>
<?php do_action( 'submit_job_form_disabled' ); ?>
<?php endif; ?>
company_listings-submit.php
" method="post" id="submit-company-form" class="job-manager-form" enctype="multipart/form-data">
<?php do_action( 'submit_company_form_start' ); ?>
<?php if ( apply_filters( 'submit_company_form_show_signin', true ) ) : ?>
<?php get_job_manager_template( 'account-signin.php', array( 'class' => $class ), 'afj-company-listings', COMPANY_LISTINGS_PLUGIN_DIR . '/templates/' ); ?>
<?php endif; ?>
<?php if ( company_listings_user_can_post_company() ) : ?>
<!-- Company Fields -->
<?php do_action( 'submit_company_form_company_fields_start' ); ?>
<?php foreach ( $company_fields as $key => $field ) : ?>
<fieldset class="fieldset-<?php esc_attr_e( $key ); ?>">
<label for="<?php esc_attr_e( $key ); ?>"><?php echo $field['label'] . apply_filters( 'submit_company_form_required_label', $field['required'] ? '' : ' <small>' . __( '(optional)', 'afj-company-listings' ) . '</small>', $field ); ?></label>
<div class="field">
<?php $class->get_field_template( $key, $field ); ?>
</div>
</fieldset>
<?php endforeach; ?>
<?php do_action( 'submit_company_form_company_fields_end' ); ?>
<p>
<?php wp_nonce_field( 'submit_form_posted' ); ?>
<input type="hidden" name="company_listings_form" value="<?php echo $form; ?>" />
<input type="hidden" name="company_id" value="<?php echo esc_attr( $company_id ); ?>" />
<input type="hidden" name="job_id" value="<?php echo esc_attr( $job_id ); ?>" />
<input type="hidden" name="step" value="<?php echo esc_attr( $step ); ?>" />
<input type="submit" name="submit_company" class="button" value="<?php esc_attr_e( $submit_button_text ); ?>" />
</p>
<?php else : ?>
<?php do_action( 'submit_company_form_disabled' ); ?>
<?php endif; ?>
<?php do_action( 'submit_company_form_end' ); ?>

Dokan seller verification page is stuck

I have little issue when I customize my Dokan address form.php because I want to delete some filed and shift between them to.. but when I finished the verification page on vonder dashboard was stuck and not responding and because it's related to setting page on the vonder dashboard so it's stuck too. So I have advance knowledge of coding and want you guys to check out if there is any mistake I did to the codes and edit it for me.
Note: I was also translate the fields from English language to Arabic.
................
<?php
/**
* Dokan Settings Address form Template
*
* #since 2.4
*
* #package dokan
*/
$address = isset( $profile_info['address'] ) ? $profile_info['address'] : '';
$address_street1 = isset( $profile_info['address']['street_1'] ) ? $profile_info['address']['street_1'] : '';
$address_street2 = isset( $profile_info['address']['street_2'] ) ? $profile_info['address']['street_2'] : '';
$address_city = isset( $profile_info['address']['city'] ) ? $profile_info['address']['city'] : '';
$address_zip = isset( $profile_info['address']['zip'] ) ? $profile_info['address']['zip'] : '';
$address_country = isset( $profile_info['address']['country'] ) ? $profile_info['address']['country'] : '';
$address_state = isset( $profile_info['address']['state'] ) ? $profile_info['address']['state'] : '';
?>
<input type="hidden" id="dokan_selected_country" value="<?php echo esc_attr( $address_country )?>" />
<input type="hidden" id="dokan_selected_state" value="<?php echo esc_attr( $address_state ); ?>" />
<div class="dokan-form-group">
<label class="dokan-w3 dokan-control-label" for="setting_address"><?php esc_html_e( 'العنوان', 'dokan-lite' ); ?></label>
<div class="dokan-w5 dokan-text-left dokan-address-fields">
<?php }
if ( $seller_address_fields['country'] ) {
$country_obj = new WC_Countries();
$countries = $country_obj->countries;
$states = $country_obj->states;
?>
<div class="dokan-form-group">
<label class="control-label" for="dokan_address[country]"><?php esc_html_e( 'الدولة ', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['country']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<select <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> name="dokan_address[country]" class="country_to_state dokan-form-control" id="dokan_address_country">
<?php dokan_country_dropdown( $countries, $address_country, false ); ?>
</select>
</div>
<?php }
if ( $seller_address_fields['state'] ) {
$address_state_class = '';
$is_input = false;
$no_states = false;
if ( isset( $states[$address_country] ) ) {
if ( empty( $states[$address_country] ) ) {
$address_state_class = 'dokan-hide';
$no_states = true;
}
} else {
$is_input = true;
}
?>
<div id="dokan-states-box" class="dokan-form-group">
<label class="control-label" for="dokan_address[state]"><?php esc_html_e( 'المحافظة ', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['state']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<?php if ( $is_input ) {
$required_attr = '';
if ( $seller_address_fields['state']['required'] ) {
$required_attr = 'required';
}
?>
<input <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> name="dokan_address[state]" class="dokan-form-control <?php echo esc_attr( $address_state_class ) ?>" id="dokan_address_state" value="<?php echo esc_attr( $address_state ) ?>"/>
<?php } else {
$required_attr = '';
if ( $seller_address_fields['state']['required'] ) {
$required_attr = 'required';
}
?>
<select <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> name="dokan_address[state]" class="dokan-form-control" id="dokan_address_state">
<?php dokan_state_dropdown( $states[$address_country], $address_state ) ?>
</select>
<?php } ?>
</div>
<?php if ( $seller_address_fields['street_1'] ) { ?>
<div class="dokan-form-group">
<label class="control-label" for="dokan_address[street_1]"><?php esc_html_e( 'الولاية ', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['street_1']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<input <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> id="dokan_address[street_1]" value="<?php echo esc_attr( $address_street1 ); ?>" name="dokan_address[street_1]" placeholder="<?php esc_attr_e( 'القرية/المنطقة' , 'dokan-lite' ) ?>" class="dokan-form-control input-md" type="text">
</div>
<?php }
if ( $seller_address_fields['street_2'] ) { ?>
<div class="dokan-form-group">
<label class="control-label" for="dokan_address[street_2]"><?php esc_html_e( 'رقم المنزل/رقم الشارع', 'dokan-lite' ); ?>
<?php
$required_attr = '';
if ( $seller_address_fields['street_2']['required'] ) {
$required_attr = 'required'; ?>
<span class="required"> *</span>
<?php } ?>
</label>
<input <?php echo esc_attr( $required_attr ); ?> <?php echo esc_attr( $disabled ) ?> id="dokan_address[street_2]" value="<?php echo esc_attr( $address_street2 ); ?>" name="dokan_address[street_2]" placeholder="<?php esc_attr_e( 'معلومات اخرى' , 'dokan-lite' ) ?>" class="dokan-form-control input-md" type="text">
</div>
<?php } ?>
<?php
/**
* Add vendor address verification templates.
*
* #since 3.4.2
*
* #param array $address Vendor address info.
* #param array $seller_address_fields Vendor required addresses.
*/
do_action( 'dokan_vendor_address_verification_template', $address, $seller_address_fields );
?>
</div>
</div>

How to style in checkout shipping in Woocommerce

I'm stuck on modifying shipping style in checkout. The goal is to redo the "Doprava" heading into a single column and shipping metods below. The shipping price should be on the right and the shipping name on the left.
I cant remove tag <.th> because then it stop works whole shipping metods.
Cart-shipping.php
<tr class="woocommerce-shipping-totals shipping">
<tr style="width:100%"><?php echo wp_kses_post( $package_name ); ?></tr>
<th data-title="<?php echo esc_attr( $package_name ); ?>" style="width:100%">
<?php if ( $available_methods ) : ?>
<ul id="shipping_method" class="woocommerce-shipping-methods">
<?php foreach ( $available_methods as $method ) : ?>
<li>
<?php
if ( 1 < count( $available_methods ) ) {
printf( '<input type="radio" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" %4$s />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ), checked( $method->id, $chosen_method, false ) ); // WPCS: XSS ok.
} else {
printf( '<input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d_%2$s" value="%3$s" class="shipping_method" />', $index, esc_attr( sanitize_title( $method->id ) ), esc_attr( $method->id ) ); // WPCS: XSS ok.
}
printf( '<label for="shipping_method_%1$s_%2$s">%3$s</label>', $index, esc_attr( sanitize_title( $method->id ) ), wc_cart_totals_shipping_method_label( $method ) ); // WPCS: XSS ok.
do_action( 'woocommerce_after_shipping_rate', $method, $index );
?>
</li>
<?php endforeach; ?>
</ul>
<?php if ( is_cart() ) : ?>
<p class="woocommerce-shipping-destination">
<?php
if ( $formatted_destination ) {
// Translators: $s shipping destination.
printf( esc_html__( 'Shipping to %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' );
$calculator_text = esc_html__( 'Change address', 'woocommerce' );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_estimate_html', __( 'Shipping options will be updated during checkout.', 'woocommerce' ) ) );
}
?>
</p>
<?php endif; ?>
<?php
elseif ( ! $has_calculated_shipping || ! $formatted_destination ) :
if ( is_cart() && 'no' === get_option( 'woocommerce_enable_shipping_calc' ) ) {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_not_enabled_on_cart_html', __( 'Shipping costs are calculated during checkout.', 'woocommerce' ) ) );
} else {
echo wp_kses_post( apply_filters( 'woocommerce_shipping_may_be_available_html', __( 'Enter your address to view shipping options.', 'woocommerce' ) ) );
}
elseif ( ! is_cart() ) :
echo wp_kses_post( apply_filters( 'woocommerce_no_shipping_available_html', __( 'There are no shipping options available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) );
else :
// Translators: $s shipping destination.
echo wp_kses_post( apply_filters( 'woocommerce_cart_no_shipping_available_html', sprintf( esc_html__( 'No shipping options were found for %s.', 'woocommerce' ) . ' ', '<strong>' . esc_html( $formatted_destination ) . '</strong>' ) ) );
$calculator_text = esc_html__( 'Enter a different address', 'woocommerce' );
endif;
?>
<?php if ( $show_package_details ) : ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php endif; ?>
<?php if ( $show_shipping_calculator ) : ?>
<?php woocommerce_shipping_calculator( $calculator_text ); ?>
<?php endif; ?>
</th>
</tr>
frontend HTML
<tr class="woocommerce-shipping-totals shipping">
<th>Doprava</th>
<td data-title="Doprava">
<ul id="shipping_method" class="woocommerce-shipping-methods">
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate1" value="flat_rate:1" class="shipping_method"><label for="shipping_method_0_flat_rate1">Zásilkovna: <span class="woocommerce-Price-amount amount"><bdi>49 <span class="woocommerce-Price-currencySymbol">Kč</span></bdi></span></label> </li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate3" value="flat_rate:3" class="shipping_method"><label for="shipping_method_0_flat_rate3">Kurýr PPL: <span class="woocommerce-Price-amount amount"><bdi>69 <span class="woocommerce-Price-currencySymbol">Kč</span></bdi></span></label> </li>
<li>
<input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_flat_rate4" value="flat_rate:4" class="shipping_method" checked="checked"><label for="shipping_method_0_flat_rate4">Česká pošta - balík do ruky: <span class="woocommerce-Price-amount amount"><bdi>89 <span class="woocommerce-Price-currencySymbol">Kč</span></bdi></span></label> </li>
</ul>
</td>
</tr>

how to query woocommerce shipping method tax price?

how to query woocommerce shipping method tax price ?
Porblem i don't tax + prive query!
Price query:
<?php if($method->cost > 0) : ?>+<span style="font-weight: normal"><?= $method->cost ?> Ft</span><?php endif; ?>
</label>
</div>
My code is:
<h2>Átvételi mód</h2>
<?php
$packages = WC()->shipping->get_packages();
$first = true;
foreach ($packages as $i => $package) {
$chosen_method = isset(WC()->session->chosen_shipping_methods[$i]) ? WC()->session->chosen_shipping_methods[$i] : '';
$product_names = array();
if (sizeof($packages) > 1) {
foreach ($package['contents'] as $item_id => $values) {
$product_names[$item_id] = $values['data']->get_name() . ' ×' . $values['quantity'];
}
$product_names = apply_filters('woocommerce_shipping_package_details_array', $product_names, $package);
}
/** #var WC_Shipping_Rate[] $available_methods */
$available_methods = $package['rates'];
$show_package_details = sizeof( $packages ) > 1;
$package_name = apply_filters( 'woocommerce_shipping_package_name', sprintf( _nx( 'Shipping', 'Shipping %d', ( $i + 1 ), 'shipping packages', 'woocommerce' ), ( $i + 1 ) ), $i, $package );
?>
<div class="shipping atvetelimod">
<td data-title="<?php echo esc_attr( $package_name ); ?>">
<?php if ( 1 < count( $available_methods ) ) : ?>
<div id="shipping_method row">
<?php
foreach ( $available_methods as $method ) : ?>
<div class="col-lg-6 balraszoveg">
<div class="jobbelvalaszto">
<label class="checkjel">
<input class="legyenelottefeher" type="radio" name="shipping_method[<?= $i ?>]" data-index="<?= $i ?>" id="shipping_method_<?= $i ?>_<?= sanitize_title( $method->id ) ?>" value="<?= esc_attr( $method->id ) ?>" class="shipping_method" <?= checked( $method->id, $chosen_method, false ) ?> />
</label>
</div>
<label class="jobboldaliszoveg" for="shipping_method_<?= $i ?>_<?= sanitize_title( $method->id ) ?>">
<strong><?= $method->get_label() ?></strong><br />
<?php if($method->cost > 0) : ?>+<span style="font-weight: normal"><?= $method->cost ?> Ft</span><?php endif; ?>
</label>
</div>
<?php endforeach; ?>
</div>
<?php elseif ( 1 === count( $available_methods ) ) : ?>
<?php
$method = current( $available_methods );
printf( '%3$s <input type="hidden" name="shipping_method[%1$d]" data-index="%1$d" id="shipping_method_%1$d" value="%2$s" class="shipping_method" />', $index, esc_attr( $method->id ), wc_cart_totals_shipping_method_label( $method ) );
do_action( 'woocommerce_after_shipping_rate', $method, $index );
?>
<?php elseif ( WC()->customer->has_calculated_shipping() ) : ?>
<?php echo apply_filters( is_cart() ? 'woocommerce_cart_no_shipping_available_html' : 'woocommerce_no_shipping_available_html', wpautop( __( 'There are no shipping methods available. Please ensure that your address has been entered correctly, or contact us if you need any help.', 'woocommerce' ) ) ); ?>
<?php elseif ( ! is_cart() ) : ?>
<?php echo wpautop( __( 'Enter your full address to see shipping costs.', 'woocommerce' ) ); ?>
<?php endif; ?>
<?php if ( $show_package_details ) : ?>
<?php echo '<p class="woocommerce-shipping-contents"><small>' . esc_html( $package_details ) . '</small></p>'; ?>
<?php endif; ?>
<?php if ( ! empty( $show_shipping_calculator ) ) : ?>
<?php woocommerce_shipping_calculator(); ?>
<?php endif; ?>
</td>
</div>
<?php }; ?>

Move Map To Bottom

I have a google map up on my contact form, I'd like to move it under my widget. I'm not sure how to go about this. I'm using WordPress Theme 'Adama.' Here is the contact form php file:
<?php
/**
* Template Name: Contact
*
* #package GalacticaThemes
* #subpackage Template
*/
get_header();
$disable_form = get_post_meta( get_the_ID(), 'adama_contact_disable_form', true );
if ( !$disable_form ) {
// Contact form
$is_sent = false;
$is_error = false;
$errors = array();
$contact_name = '';
$contact_email = '';
$contact_phone = '';
$contact_subject = '';
$contact_message = '';
// If the form is submitted
if ( isset( $_POST['contact_submitted'] ) ) {
// Name
if ( isset( $_POST['contact_name'] ) ) {
$contact_name = strip_tags( trim( $_POST['contact_name'] ) );
}
if ( $contact_name === '' ) {
// Name is required
$errors['contact_name'] = esc_html__( 'You forgot to enter your name.', 'adama' );
$is_error = true;
}
// Email
if ( isset( $_POST['email'] ) ) {
$contact_email = strip_tags( trim( $_POST['email'] ) );
}
if ( $contact_email === '' ) {
// Email is required
$errors['contact_email'] = esc_html__( 'You forgot to enter your email address.', 'adama' );
$is_error = true;
} else if ( !is_email( $contact_email ) ) {
// Validate email address
$errors['contact_email'] = esc_html__( 'You entered an invalid email address.', 'adama' );
$is_error = true;
} else {
$contact_email = sanitize_email( $contact_email );
}
// Phone
if ( isset( $_POST['contact_phone'] ) ) {
$contact_phone = strip_tags( trim( $_POST['contact_phone'] ) );
}
// Subject
if ( isset( $_POST['contact_subject'] ) ) {
$contact_subject = strip_tags( trim( $_POST['contact_subject'] ) );
}
if ( $contact_subject === '' ) {
// Subject is required
$errors['contact_subject'] = esc_html__( 'You forgot to enter message subject.', 'adama' );
$is_error = true;
}
// Message
if ( isset( $_POST['contact_message'] ) ) {
$contact_message = sanitize_text_field( strip_tags( trim( $_POST['contact_message'] ) ) );
}
if ( $contact_message === '' ) {
// Message is required
$errors['contact_message'] = esc_html__( 'You forgot to enter your message.', 'adama' );
$is_error = true;
}
// If there is no error, send email
if ( !$is_error ) {
$email_to = galactica_option_email( 'contact_email' );
$headers = esc_html__( 'From: ', 'adama' ) . "$contact_name <$contact_email>\r\n" . esc_html__( 'Reply-To: ', 'adama' ) . $contact_email;
$subject = sprintf(
esc_html__( '[%1$s - Contact] %2$s', 'adama' ),
get_bloginfo( 'name' ),
$contact_subject
);
$body = sprintf(
esc_html__( "Name: %s \n\nPhone: %s \n\nEmail: %s \n\nMessage: %s \n\n\n\nNote: This message was sent from contact form on %s website.", 'adama' ),
$contact_name,
$contact_phone,
$contact_email,
$contact_message,
get_bloginfo( 'name' )
);
$is_sent = wp_mail( $email_to, $subject, $body, $headers );
if ( !$is_sent ) {
$is_error = true;
}
}
}
}
// Map position
$map_position = get_post_meta( get_the_ID(), 'adama_contact_map_position', true );
$map_position = galactica_lower_in_array( $map_position, array( 'top', 'side' ), 'top' );
?>
<?php if ( $map_position === 'top' ) : ?>
<section>
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</section>
<?php endif; ?>
<section class="w-section">
<div class="container">
<div class="row">
<div id="content" class="col-md-7 col-content">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php if ( !post_password_required() && !$disable_form ) : ?>
<form method="post" action="<?php echo esc_url( get_permalink( get_the_ID() ) ); ?>" id="contact-form" role="form">
<?php if ( $is_sent ) : ?>
<div class="alert alert-success">
<?php esc_html_e( 'Your message was sent successfully.', 'adama' ); ?>
</div>
<?php else : ?>
<?php if ( $is_error ) : ?>
<div class="alert alert-danger">
<?php esc_html_e( 'There was an error submitting the form. Please check that you have entered valid information and try again.', 'adama' ); ?>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
</div>
<?php endif; ?>
<div class="form-wrapper">
<div class="form-group">
<label for="contact_name"><?php esc_html_e( 'Name', 'adama' ); ?></label>
<input type="text" name="contact_name" id="contact_name" class="form-control form-control-validate-required" placeholder="<?php esc_attr_e( 'Your name', 'adama' ); ?>" value="<?php echo esc_attr( $contact_name ); ?>" />
<?php adama_form_error( $errors, 'contact_name' ); ?>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="contact_email"><?php esc_html_e( 'Email', 'adama' ); ?></label>
<input type="email" name="email" id="contact_email" class="form-control form-control-validate-required form-control-validate-email" placeholder="<?php esc_attr_e( 'Email address', 'adama' ); ?>" value="<?php echo esc_attr( $contact_email ); ?>" />
<?php adama_form_error( $errors, 'contact_email' ); ?>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="contact_phone"><?php esc_html_e( 'Phone', 'adama' ); ?></label>
<input type="text" name="contact_phone" id="contact_phone" class="form-control" placeholder="<?php esc_attr_e( 'Phone number', 'adama' ); ?>" value="<?php echo esc_attr( $contact_phone ); ?>" />
<?php adama_form_error( $errors, 'contact_phone' ); ?>
</div>
</div>
</div>
<div class="form-group">
<label for="contact_subject"><?php esc_html_e( 'Subject', 'adama' ); ?></label>
<input type="text" name="contact_subject" id="contact_subject" class="form-control form-control-validate-required" placeholder="<?php esc_attr_e( 'Subject', 'adama' ); ?>" value="<?php echo esc_attr( $contact_subject ); ?>" />
<?php adama_form_error( $errors, 'contact_subject' ); ?>
</div>
<div class="form-group">
<label for="contact_message"><?php esc_html_e( 'Message', 'adama' ); ?></label>
<textarea name="contact_message" id="contact_message" class="form-control form-control-validate-required contact-message" placeholder="<?php esc_attr_e( 'Write you message here...', 'adama' ); ?>"><?php echo esc_textarea( $contact_subject ); ?></textarea>
<?php adama_form_error( $errors, 'contact_message' ); ?>
</div>
<input type="hidden" name="contact_submitted" value="1" />
<button type="submit" class="btn btn-two" name="send"><?php esc_html_e( 'Send message', 'adama' ); ?></button>
</div>
<?php endif; ?>
</form>
<?php endif; ?>
<?php endwhile; ?>
</div><!-- #content -->
<?php get_sidebar( 'contact' ); ?>
</div>
</div>
</section>
<?php if ( !$disable_form ) { ?>
<script>
/* global jQuery */
// Javascript validation
jQuery( document ).ready( function( $ ) {
"use strict";
var $form = $( 'form#contact-form' );
$form.submit( function( e ) {
// Remove old error messages
$form.find( '.alert' ).remove();
// Validate
var hasError = false;
$form.find( '.form-control-validate-required' ).each( function() {
var $ctrl = $( this ),
labelText,
value = $.trim( $ctrl.val() );
if ( value === '' ) {
hasError = true;
labelText = $ctrl.prev( 'label' ).text();
$ctrl.parent().append( '<div class="alert alert-danger alert-form-message"><?php esc_html_e( 'You forgot to enter your', 'adama' ); ?> ' + labelText + '.</div>' );
} else if ( $ctrl.hasClass( 'form-control-validate-email' ) && !( /^([\w-\.]+#([\w-]+\.)+[\w-]{2,4})?$/.test( value ) ) ) {
hasError = true;
labelText = $ctrl.prev( 'label' ).text();
$ctrl.parent().append( '<div class="alert alert-danger alert-form-message"><?php esc_html_e( 'You entered an invalid', 'adama' ); ?> ' + labelText + '.</div>' );
}
});
// If no errors submit form via ajax
if ( hasError ) {
$form.prepend( '<div class="alert alert-danger"><?php esc_html_e( 'There was an error submitting the form. Please check that you have entered valid information and try again.', 'adama' ); ?><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>' );
} else {
var formData = $(this).serialize();
$.post( $( this ).attr( 'action' ), formData, function( data ) {
if ( data.indexOf( '<?php esc_html_e( 'Your message was sent successfully.', 'adama' ); ?>' ) !== -1 ) {
$form.find( '.form-wrapper' ).slideUp( 'fast', function() {
$form.prepend( '<div class="alert alert-success"><?php esc_html_e( 'Your message was sent successfully.', 'adama' ); ?></div>' );
});
} else {
$form.prepend( '<div class="alert alert-danger"><?php esc_html_e( 'There was an error submitting the form. Please check that you have entered valid information and try again.', 'adama' ); ?><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>' );
}
});
}
e.preventDefault();
});
});
</script>
<?php } ?>
<?php get_footer();
That currently shows up like this with these settings:
I would love to move the map to the bottom of the widget, but I'm not sure how... The theme settings only currently have "top" (which is a full width above the form and widget) and the side which also appears on top of the widget...
Edit:
Here's Sidebar.php
<?php
/**
* The sidebar containing the widget area
*
* Displays on posts and pages.
*
* #package GalacticaThemes
* #subpackage Template
*/
?>
<?php if ( galactica_is_sidebar_enabled() ) : ?>
<div id="sidebar" class="col-md-3 widget-area sidebar-classic" role="complementary">
<?php galactica_dynamic_sidebar(); ?>
</div><!-- #sidebar -->
<?php endif; ?>
Here's Contact Sidebar
<?php
/**
* The sidebar containing the contact page widget area
*
* #package GalacticaThemes
* #subpackage Template
*/
// Map position
$map_position = get_post_meta( get_the_ID(), 'adama_contact_map_position', true );
$map_position = galactica_lower_in_array( $map_position, array( 'top', 'side' ), 'top' );
?>
<?php if ( galactica_is_sidebar_enabled() ) : ?>
<div id="sidebar" class="col-md-5 widget-area sidebar-classic" role="complementary">
<?php if ( $map_position === 'side' ) : ?>
<div class="widget">
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</div>
<?php endif; ?>
<?php galactica_dynamic_sidebar(); ?>
</div><!-- #sidebar -->
<?php endif; ?>
Looks like I might just have to move the map under in this file above here!
Not tested, obviously but I think you can just flip these two like this inside your contact sidebar file so the info is being called in before the map.
<?php galactica_dynamic_sidebar(); ?>
<?php if ( $map_position === 'side' ) : ?>
<div class="widget">
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</div>
<?php endif; ?>
In sidebar-contact.php just flip the lines:
<?php
/**
* The sidebar containing the contact page widget area
*
* #package GalacticaThemes
* #subpackage Template
*/
// Map position
$map_position = get_post_meta( get_the_ID(), 'adama_contact_map_position', true );
$map_position = galactica_lower_in_array( $map_position, array( 'top', 'side' ), 'top' );
?>
<?php if ( galactica_is_sidebar_enabled() ) : ?>
<div id="sidebar" class="col-md-5 widget-area sidebar-classic" role="complementary">
<?php galactica_dynamic_sidebar(); ?>
<?php if ( $map_position === 'side' ) : ?>
<div class="widget">
<?php // Google Map
echo galactica_map( array(
'type' => galactica_option( 'contact_map_type', 'road' ),
'address' => implode( '|', galactica_option( 'contact_map_address', array() ) ),
'tooltip' => '',
'height' => galactica_option( 'contact_map_height', 'road' ) . 'px',
'zoom' => galactica_option( 'contact_map_zoom', 15 ),
'scrollwheel_enabled' => false,
)); ?>
</div>
<?php endif; ?>
</div><!-- #sidebar -->
<?php endif; ?>
This will give the desired request with the map under the widget!

Categories