/**
* Получает экстремальнве значения ценв в категории товара
* @param $term_id - id категории товара
*
* @return mixed
*/
function wpp_get_extremes_price_in_product_cat( $term_id ) {
global $wpdb;
$sql = "
SELECT MIN( meta_value ) as min_price , MAX( meta_value ) as max_price
FROM {$wpdb->posts}
INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)
INNER JOIN {$wpdb->postmeta} ON ({$wpdb->posts}.ID = {$wpdb->postmeta}.post_id)
WHERE
( {$wpdb->term_relationships}.term_taxonomy_id IN (%d) )
AND {$wpdb->posts}.post_type = 'product'
AND {$wpdb->posts}.post_status = 'publish'
AND {$wpdb->postmeta}.meta_key = '_price'
";
$result = $wpdb->get_results( $wpdb->prepare( $sql, $term_id ) );
return $result[ 0 ];
}
add_action( 'after_setup_theme', 'woocommerce_support' );
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
#json в данном примере содержит полученые от гугла данные
for (i = 0; i < json.length; i++) {
var name = json[i].name;
var address = name;
var point = new google.maps.LatLng(json[i].lat, json[i].lng);
marker = createMarker(point, name, address);
bounds.extend(point);
}
map.fitBounds(bounds)
foreach ( $attributes as $attribute ) :
$values = array();
if ( $attribute->is_taxonomy() ) {
$attribute_taxonomy = $attribute->get_taxonomy_object();
$attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( 'fields' => 'all' ) );
foreach ( $attribute_values as $attribute_value ) {
$value_name = esc_html( $attribute_value->name );
if ( $attribute_taxonomy->attribute_public ) {
$values[] = '<a href="' . esc_url( get_term_link( $attribute_value->term_id, $attribute->get_name() ) ) . '" rel="tag">' . $value_name . '</a>';
} else {
$values[] = $value_name;
}
}
} else {
$values = $attribute->get_options();
foreach ( $values as $value ) {
$value = make_clickable( esc_html( $value ) );
}
}
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
endforeach;