/**
* Get product variation dimensions
* @param $product_id int product_id
*
* @return array product variation dimensions
*/
function wpp_get_product_variation_dimensions($product_id) {
$product = get_product( $product_id );
$out = array();
if ( $product->is_type( 'variable' ) ) {
$variations = $product->get_available_variations();
foreach ( $variations as $variable_array ) {
$variation = new WC_Product( $variable_array[ 'variation_id' ] );
$out[ 'variation_' . $variation->id ] = array(
'weight' => $variation->weight,
'length' => $variation->length,
'width' => $variation->width,
'height' => $variation->height
);
}
}
return $out;
}
$tt = wpp_get_product_variation_dimensions(133821);
array( 2 ) {
[ "variation_133823" ]=>
array( 4 ) {
[ "weight" ]=>
string( 1 ) "3"
[ "length" ]=>
string( 3 ) "500"
[ "width" ]=>
string( 3 ) "700"
[ "height" ]=>
string( 3 ) "200"
}
[ "variation_133824" ]=>
array( 4 ) {
[ "weight" ]=>
string( 1 ) "2"
[ "length" ]=>
string( 3 ) "200"
[ "width" ]=>
string( 3 ) "270"
[ "height" ]=>
string( 3 ) "500"
}
}
function wpp_get_acf_field_value($atts) {
$args = shortcode_atts( array(
'key' => '',
'post_id' => '',
), $atts );
$id = !empty( $args[ 'post_id' ] ) ? (int) $args[ 'post_id' ] : '';
if ( !empty( $args[ 'key' ] ) ) {
return get_field( esc_attr( $args[ 'key' ] ), $id );
} else {
return __( 'Не задан ключ поля', 'textdomain' );
}
}
add_shortcode('wpp_acf_field','wpp_get_acf_field_value')
<?php
$main ='';
$thumb ='';
while ( have_posts() ) : the_post();
$image = get_field('img');
$main .= sprintf('<div class="slider-for"><div><div style="background-image: url(%s)" class="slider__inner"></div></div></div>', $image['url']);
$thumb .= sprintf('<div><div style="background-image: url(%s)" class="slider__inner"></div></div>', $image['url']);
endwhile;
printf('<div class="slider-content">%s</div><div class="slider-nav">%s</div>',$main,$thumb);
function cs_addto_usermeta_carosel() {
$user_data = get_userdata( get_current_user_id() );
if( 'subscriber' === $user_data->roles[0] )
wp_die();
/** Остальной код **/
}
add_action("wp_ajax_nopriv_cs_addto_usermeta_carosel", "cs_addto_usermeta_carosel");
<ul class="site-header-cart menu">
<li class="<?php echo esc_attr( $class ); ?>">
<!-- код вывода подробностей о текущем состоянии корзины -->
</li>
<li>
<!-- выпадающий блок корзины-->
<?php the_widget( 'WC_Widget_Cart', 'title=' ); ?>
</li>
</ul>
<ul class="site-header-cart menu">
<li class="<?php echo esc_attr( $class ); ?>">
<?php a href="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>"><!-- код вывода подробностей о текущем состоянии корзины --></a>
</li>
</ul>
/**
* Замена спиннера
* @param $located
* @param $template_name
* @param $args
* @param $template_path
* @param $default_path
* @return string
*/
function filter_сr_woo_quantity_inputs( $located, $template_name, $args, $template_path, $default_path ){
if('global/quantity-input.php' === $template_name ) {
return __DIR__ .'/cr-quantity-input.php';
} else {
return $located;
}
};
add_filter( 'wc_get_template', 'filter_сr_woo_quantity_inputs', 10, 5 );