Reset/Refresh Search Form Button in WordPress Theme - php

First time posting. I appreciate any help in advance. I really appreciate it.
I am currently work with a wordpress theme to search villas around the world and I would love to add a reset button that would clear the fields, drop downs and check boxes that are populated by a custom fields app. The normal reset button does not work and since I am teaching myself PHP on the fly I am at a loss. Here is the link to the page and I will paste some of the code so you get an idea of what I am looking at.
I really appreciate any help since the theme author has been blowing me off.
LINK
<?php
global $realty_theme_option, $wp_query;
?>
<form class="property-search-form border-box" action="<?php if ( tt_page_id_template_search() ) { echo get_permalink( tt_page_id_template_search() ); } ?>">
<div class="row">
<?php if ( isset( $realty_theme_option['property-search-results-page'] ) && empty( $realty_theme_option['property-search-results-page'] ) ) { ?>
<div class="col-xs-12" style="margin-bottom: 1em">
<p class="alert alert-info"><?php esc_html_e( 'Please go to "Appearance > Theme Options > Pages" and set the page you want to use as your property search results.', 'realty' ); ?></p>
</div>
<?php } ?>
<?php
// Form select classes
$form_select_class = 'form-control';
if ( $realty_theme_option['enable-rtl-support'] || is_rtl() ) {
$form_select_class .= ' chosen-select chosen-rtl';
} else {
$form_select_class .= ' chosen-select';
}
$acf_field_array = array();
if ( isset( $realty_theme_option['property-search-features'] ) && ! tt_is_array_empty( $realty_theme_option['property-search-features'] ) ) {
$property_search_features = $realty_theme_option['property-search-features'];
} else {
$property_search_features = null;
}
$raw_search_params = get_query_var( 'property_search_parameters' );
if ( ! tt_is_array_empty( $raw_search_params ) ) {
$search_parameters = $raw_search_params;
} else if ( isset( $realty_theme_option['property-search-parameter'] ) && ! empty( $realty_theme_option['property-search-parameter'] ) ) {
$search_parameters = $realty_theme_option['property-search-parameter'];
} else {
$search_parameters = null;
}
$raw_search_fields = get_query_var('property_search_fields');
if ( ! tt_is_array_empty( $raw_search_fields ) ) {
$search_fields = $raw_search_fields;
} else if ( isset( $realty_theme_option['property-search-parameter'] ) && ! empty( $realty_theme_option['property-search-parameter'] ) ) {
$search_fields = $realty_theme_option['property-search-field'];
} else {
$search_fields = null;
}
$raw_search_labels = get_query_var('property_search_labels');
if ( ! tt_is_array_empty( $raw_search_labels ) ) {
$search_labels = $raw_search_labels;
} else if ( isset( $realty_theme_option['property-search-label'] ) && ! empty( $realty_theme_option['property-search-label'] ) ) {
$search_labels = $realty_theme_option['property-search-label'];
} else {
$search_labels = null;
}
$default_search_fields_array = array(
'estate_search_by_keyword',
'estate_property_id',
'estate_property_location',
'estate_property_type',
'estate_property_status',
'estate_property_price',
'estate_property_price_min',
'estate_property_price_max',
'estate_property_pricerange',
'estate_property_size',
'estate_property_rooms',
'estate_property_bedrooms',
'estate_property_bathrooms',
'estate_property_garages',
'estate_property_available_from'
);
$i = 0;
if ( isset( $search_form_columns ) && ! empty( $search_form_columns ) ) {
// Use $columns parameter from shortcode [property_search_form]
$count_search_fields = $search_form_columns;
} else {
// No shortcode $columns found, pick columns according to total field count
$count_search_fields = count( $search_fields );
}
if ( $count_search_fields == 1 ) {
$columns = 'col-xs-12';
} else if ( $count_search_fields == 2 ) {
$columns = 'col-xs-12 col-sm-6';
} else if ( $count_search_fields == 3 ) {
$columns = 'col-xs-12 col-sm-6 col-md-4';
} else {
$columns = 'col-xs-12 col-sm-4 col-md-3';
}
if ( is_page_template( 'template-map-vertical.php' ) ) {
$columns = 'col-xs-12 col-sm-6';
}
// Do we have any search parameters defined?
if ( isset( $search_parameters ) && ! empty( $search_parameters[0] ) ) {
foreach ( $search_fields as $search_field ) {
$search_parameter = $search_parameters[$i];
// Check If Search Field Is Filled Out
if ( ! empty( $search_field ) ) {
// Default Property Field
if ( in_array( $search_field, $default_search_fields_array ) ) {
switch ( $search_field ) {
case 'estate_search_by_keyword' :
case 'estate_property_id' :
?>
<div class="<?php echo $columns; ?> form-group">
<input type="text" name="<?php echo $search_parameter; ?>" id="<?php echo $search_parameter; ?>" value="<?php echo isset( $_GET[$search_parameter]) ? $_GET[$search_parameter] : ''; ?>" placeholder="<?php echo $search_labels[$i]; ?>" class="form-control" />
</div>
<?php
break;
case 'estate_property_location' : ?>
<div class="<?php echo $columns; ?> form-group select">
<?php
// http://wordpress.stackexchange.com/questions/14652/how-to-show-a-hierarchical-terms-list#answer-14658
if ( ! empty( $search_labels[$i] ) ) {
$search_label_location = $search_labels[$i];
} else {
$search_label_location = esc_html__( 'Any Location', 'realty' );
}
?>
<select name="<?php echo $search_parameter; ?>" id="<?php echo $search_parameter; ?>" class="<?php echo esc_attr( $form_select_class ); ?>">
<option value="all"><?php echo $search_label_location; ?></option>
<?php
$location = get_terms('property-location', array(
'orderby' => 'slug',
'parent' => 0,
'hide_empty' => false
) );
if ( isset( $_GET[$search_parameter] ) ) {
$get_location = $_GET[$search_parameter];
} else {
$get_location = null;
}
?>
<?php foreach ( $location as $key => $location ) : ?>
<option value="<?php echo $location->slug; ?>" <?php selected( $location->slug, $get_location ); ?>>
<?php
echo $location->name;
$location2 = get_terms( 'property-location', array(
'orderby' => 'slug',
'parent' => $location->term_id
) );
if ( $location2 ) :
?>
<optgroup>
<?php foreach( $location2 as $key => $location2 ) : ?>
<option value="<?php echo $location2->slug; ?>" class="level2" <?php selected( $location2->slug, $get_location ); ?>>
<?php
echo $location2->name;
$location3 = get_terms( 'property-location', array(
'orderby' => 'slug',
'parent' => $location2->term_id
) );
if ( $location3 ) :
?>
<optgroup>
<?php foreach( $location3 as $key => $location3 ) : ?>
<option value="<?php echo $location3->slug; ?>" class="level3" <?php selected( $location3->slug, $get_location ); ?>>
<?php
echo $location3->name;
$location4 = get_terms( 'property-location', array( 'orderby' => 'slug', 'parent' => $location3->term_id ) );
if( $location4 ) :
?>
<optgroup>
<?php foreach( $location4 as $key => $location4 ) : ?>
<option value="<?php echo $location4->slug; ?>" class="level4" <?php selected( $location4->slug, $get_location ); ?>>
<?php echo $location4->name; ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
</option>
<?php endforeach; ?>
</select>
</div>

There's a line of code that needs modifying
Reset Form
That element does not exist, the form has a class called property-search-form which you could use as the selector.
So replace the line with something like
Reset Form

Related

WordPress google map showing the marker as "undefined"

Hi I'm currently experiencing a problem on my Wordpress website with the map, its showing that the marker is undefined like on this page here, how would i go about fixing this here is the code its pulling from:
<footer class="card__footer">
<?php
$rating = get_average_listing_rating( $post->ID, 1 );
$geolocation_street = get_post_meta( $post->ID, 'geolocation_street', true );
if ( ! empty( $rating ) ) { ?>
<div class="rating card__rating" itemprop="aggregateRating" itemscope
itemtype="http://schema.org/AggregateRating">
<meta itemprop="ratingValue"
content="<?php echo get_average_listing_rating( $post->ID, 1 ); ?>">
<meta itemprop="reviewCount" content="<?php echo get_comments_number( $post->ID ) ?>; ?>">
<span class="js-average-rating"><?php echo get_average_listing_rating( $post->ID, 1 ); ?></span>
</div>
<?php } elseif ( ! empty( $geolocation_street ) ) { ?>
<div class="card__rating card__pin">
<?php get_template_part( 'assets/svg/pin-simple-svg' ) ?>
</div>
<?php }
if ( ! is_wp_error( $terms ) && ( is_array( $terms ) || is_object( $terms ) ) ) { ?>
<ul class="card__tags">
<?php foreach ( $terms as $term ) {
$icon_url = listable_get_term_icon_url( $term->term_id );
$attachment_id = listable_get_term_icon_id( $term->term_id );
if ( empty( $icon_url ) ) {
continue;
} ?>
<li>
<div class="card__tag">
<div class="pin__icon">
<?php listable_display_image( $icon_url, '', true, $attachment_id ); ?>
</div>
</div>
</li>
<?php } ?>
</ul><!-- .card__tags -->
<?php }
$listing_address = listable_get_formatted_address( $post );
if ( ! empty( $listing_address ) ) { ?>
<div class="address card__address" itemprop="address" itemscope
itemtype="http://schema.org/PostalAddress">
<?php echo $listing_address ?>
</div>
<?php } ?>
</footer>
New to PHP, Thank you in advance!

Add collapse for submenus in dropdown wordpress

I am using a plugin WCFM in which there is a filter to show Vendors on basis of categories, currently subcategories is having ----- sign before the title, what I want is to add collapse for Categories.
Example: when user click on category name then collapsed subcategories should show to user and user can select the subcategory.
As of now I have more than 50 subcategories for each 10 categories, which makes list very lengthy, collapse will solve the issue.
Code:
<?php if( $category && apply_filters( 'wcfmmp_is_allow_store_list_category_filter', true ) ) { ?>
<?php
$vendor_categories = $WCFMmp->wcfmmp_vendor->wcfmmp_get_vendor_taxonomy( 0, 'product_cat' );
if ( $vendor_categories ) {
$preferred_taxonomy = 'product_cat';
?>
<select id="wcfmmp_store_category" name="wcfmmp_store_category" class="wcfm-select wcfm_ele">
<option value=""><?php _e( 'Choose Category', 'wc-multivendor-marketplace' ); ?></option>
<?php
foreach( $vendor_categories as $vendor_category_id => $vendor_category ) {
if( $vendor_category_id ) {
if( !apply_filters( 'wcfm_is_allow_store_list_taxomony_by_id', true, $vendor_category_id, $preferred_taxonomy ) ) continue;
if( is_array( $vendor_category ) && !empty( $vendor_category ) ) {
$vendor_term = get_term( absint( $vendor_category_id ), $preferred_taxonomy );
$tax_toggle_class = '';
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>><?php echo $vendor_term->name; ?></option>
<?php
}
foreach( $vendor_category as $vendor_category_child_id => $vendor_category_child ) {
$vendor_term = get_term( absint( $vendor_category_child_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>—<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>—<?php echo $vendor_term->name; ?></option>
<?php
foreach( $vendor_category_child as $vendor_category_child2_id => $vendor_category_child2 ) {
$vendor_term = get_term( absint( $vendor_category_child2_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child2 ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>——<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>——<?php echo $vendor_term->name; ?></option>
<?php
foreach( $vendor_category_child2 as $vendor_category_child3_id => $vendor_category_child3 ) {
$vendor_term = get_term( absint( $vendor_category_child3_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child3 ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>———<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>———<?php echo $vendor_term->name; ?></option>
<?php
foreach( $vendor_category_child3 as $vendor_category_child4_id => $vendor_category_child4 ) {
$vendor_term = get_term( absint( $vendor_category_child4_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child4 ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>————<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>————<?php echo $vendor_term->name; ?></option>
<?php
foreach( $vendor_category_child4 as $vendor_category_child5_id => $vendor_category_child5 ) {
$vendor_term = get_term( absint( $vendor_category_child5_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child5 ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>—————<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>—————<?php echo $vendor_term->name; ?></option>
<?php
foreach( $vendor_category_child5 as $vendor_category_child6_id => $vendor_category_child6 ) {
$vendor_term = get_term( absint( $vendor_category_child6_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child6 ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>——————<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>——————<?php echo $vendor_term->name; ?></option>
<?php
foreach( $vendor_category_child6 as $vendor_category_child7_id => $vendor_category_child7 ) {
$vendor_term = get_term( absint( $vendor_category_child7_id ), $preferred_taxonomy );
if( !is_array( $vendor_category_child7 ) ) {
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>———————<?php echo $vendor_term->name; ?></option>
<?php
}
} else {
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>>———————<?php echo $vendor_term->name; ?></option>
<?php
}
}
}
}
}
}
}
}
}
}
}
}
}
}
} else {
$vendor_term = get_term( absint( $vendor_category_id ), $preferred_taxonomy );
if( $vendor_term && $vendor_term->term_id && $vendor_term->name ) {
if( in_array( $vendor_term->term_id, $display_vendor_term) ) continue;
$display_vendor_term[$vendor_term->term_id] = $vendor_term->term_id;
?>
<option value="<?php echo $vendor_term->term_id; ?>" <?php if( $vendor_term->term_id == $search_category ) echo 'selected'; ?>><?php echo $vendor_term->name; ?></option>
<?php
}
}
}
}
?>
</select>
<?php } ?>
<?php do_action( 'wcfmmp_after_store_list_category_filter', $args ); ?>
<?php } ?>

Modify Wordpress Custom Price Plug-In

I tried modifying this plug-in for WordPress:
https://easydigitaldownloads.com/downloads/custom-prices/?utm_campaign=documentation&utm_source=helpscout&utm_medium=doc&utm_term=1975-custom-prices-overview
What I'm trying to achieve is moving the $ sign next to the custom price field or alternatively removing it completely.
/*
* Hook into add to cart post
*/
function edd_cp_purchase_link_top( $download_id ) {
global $edd_options;
$default_price = get_post_meta( $download_id, 'edd_cp_default_price', true );
$min_price = edd_format_amount ( get_post_meta( $download_id, 'edd_cp_min', true ) );
$custom_price = isset( $_GET ['cp_price'] ) ? edd_format_amount( $_GET ['cp_price'] ) : '';
$button_text = get_post_meta( $download_id, 'cp_button_text', true );
if ( empty( $custom_price ) && ! empty( $default_price ) ) {
$custom_price = edd_format_amount( $default_price );
}
if ( edd_cp_has_custom_pricing( $download_id ) && ! edd_single_price_option_mode( $download_id ) ) {
$wrapper_display = '';
$download = new EDD_Download( $download_id );
if ( edd_item_in_cart( $download_id, array() ) && ( ! $download->has_variable_prices() || ! $download->is_single_price_mode() ) ) {
$wrapper_display = 'style="display:none;"';
} ?>
<p class="edd-cp-container" <?php echo $wrapper_display; ?>>
<?php
echo __( 'Name your price', 'edd_cp' );
if ( ! isset( $edd_options['currency_position'] ) || $edd_options['currency_position'] == 'before' ) : ?>
<?php echo edd_currency_filter( '' ); ?> <input type="text" name="edd_cp_price" class="edd_cp_price" value="<?php echo esc_attr( $custom_price ); ?>" size="30" data-min="<?php echo $min_price; ?>" style="width: 40px;" data-default-text="<?php echo esc_attr( $button_text ); ?>" />
<?php else : ?>
<input type="text" name="edd_cp_price" class="edd_cp_price" value="<?php echo esc_attr( $custom_price ); ?>" size="30" data-min="<?php echo $min_price; ?>" style="width: 80px;" data-default-text="<?php echo esc_attr( $button_text ); ?>" /><?php echo edd_currency_filter( '' );
endif;
$min_no_format = floatval( $min_price );
if( !empty( $min_no_format ) ) {
echo ' <small>(min '.edd_currency_filter( ( $min_price ) ).')</small>';
} ?>
</p>
<?php
}
}
add_filter( 'edd_purchase_link_top', 'edd_cp_purchase_link_top' );
/*
* Add additional list item if variable pricing is enabled
*/
function edd_cp_after_price_options_list( $key, $price, $download_id ) {
if( ! edd_cp_has_custom_pricing( $download_id ) ) {
return;
}
if ( ! edd_single_price_option_mode( $download_id ) ) {
return;
}
global $edd_options;
$default_price_option = edd_get_default_variable_price( $download_id );
$display = 'none';
if ( $key === $default_price_option ) {
$display = 'block';
} ?>
<div class="edd-cp-price-option-wrapper" style="display: <?php echo esc_attr( $display ); ?>;">
<?php
echo __( 'Name your price', 'edd_cp' );
if ( ! isset( $edd_options['currency_position'] ) || $edd_options['currency_position'] == 'before' ) : ?>
<?php echo edd_currency_filter( '' ); ?> <input type="text" name="edd_cp_price[<?php echo esc_attr( $key ); ?>]" class="edd_cp_price" value="<?php echo esc_attr( $price['amount'] ); ?>" size="30" data-min="" />
<?php else : ?>
<input type="text" name="edd_cp_price[<?php echo esc_attr( $key ); ?>]" class="edd_cp_price" value="<?php echo esc_attr( $price['amount'] ); ?>" size="30" data-min="" data-default-text="<?php echo esc_attr( $button_text ); ?>" /><?php echo edd_currency_filter( '' );
endif; ?>
</div>
<?php }
add_action( 'edd_after_price_option', 'edd_cp_after_price_options_list', 10, 3 );
See the attached image. This is how it currently looks.
I really appreciate your help!

Saving metabox value not working [WP-PHP]

I'm trying to save a metabox input but it doesn't seem to work. I'm working with arrays (as I need my metabox to have 60 rows), so I assume the problem lies within them.
This is my metabox function for the admin (which works correctly showing the info I wanna show):
function mock_metabox() {
global $post;
// Nonce field
wp_nonce_field( basename( __FILE__ ), 'mock_fields' );
// init counter for meta array
$contadorglobal = 1;
$selecciones = array();
$equipos = array();
$equiposog = array();
while ( $contadorglobal <= 60 ){
$selecciones[$contadorglobal-1] = get_post_meta( $post->ID, '_seleccion_' . $contadorglobal, true );
$equipos[$contadorglobal-1] = get_post_meta( $post->ID, '_equipo_' . $contadorglobal, true );
$equiposog[$contadorglobal-1] = get_post_meta( $post->ID, '_equipoog_' . $contadorglobal, true );
$contadorglobal++;
}
// Output the fields
?>
<h3> Informacion del Mock </h3>
<table>
<tr>
<th> # </th>
<th> Jugador </th>
<th> Equipo </th>
<th> Equipo Original </th>
</tr>
<?
$contador = 1;
$teams = get_posts( array(
'post_type' => 'team',
'orderby' => 'title',
'order' => 'ASC',
'numberposts' => -1,
'post_status' => 'publish'
) );
while ( $contador <= 60 ){
?>
<tr>
<td><?php echo $contador ?></td>
<td><input type="text" name="<? 'jugador_' . $contador ?>" value="<?php echo $selecciones[$contador-1] ; ?>" />
<td><select name="<? 'equipo_' . $contador?>" ><?
foreach ( $teams as $team ) { ?>
<option value="<?php echo $team->ID; ?>" <?php checked( $equipos[$contador-1], $team->ID ); ?> > <?php echo $team->post_title; ?> </option> <? } ?> </select> </td>
<td><select name="<? 'equipoog_' . $contador ?>" ><?
foreach ( $teams as $team ) { ?>
<option value="<?php echo $team->ID; ?>" <?php checked( $equiposog[$contador-1], $team->ID ); ?> > <?php echo $team->post_title; ?> </option> <? } ?> </select> </td>
<? $contador++; ?>
</tr>
<?php } ?>
</table>
<?}
And this is the saving function (I thought the problem was with the while, but I tried removing it and it doesn't save any info either).
function mock_save_meta_box_data( $post_id ){
// verify taxonomies meta box nonce
if ( !isset( $_POST['mock_fields'] ) || !wp_verify_nonce( $_POST['mock_fields'], basename( __FILE__ ) ) ){
return;
}
// return if autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
return;
}
// Check the user's permissions.
if ( ! current_user_can( 'edit_post', $post_id ) ){
return;
}
// guarda tipo traspaso
for ($contadorid = 1; $contadorid <= 60; $contadorid++) {
if ( isset( $_REQUEST['jugador_' . $contadorid] ) ) {
update_post_meta( $post_id, '_seleccion_' . $contadorid, $_POST['jugador_' . $contadorid] );
}
if ( isset( $_REQUEST['equipo_' . $contadorid] ) ) {
update_post_meta( $post_id, '_equipo_' . $contadorid, $_POST['equipo_' . $contadorid] );
}
if ( isset( $_REQUEST['equipoog_' . $contadorid] ) ) {
update_post_meta( $post_id, '_equipoog_' . $contadorid, $_POST['equipoog_' . $contadorid] );
}
}
}
add_action( 'save_post_mock', 'mock_save_meta_box_data' );
Any ideas? Thanks in advance!

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 }; ?>

Categories