<div class="button-submit" style="text-align:right;">
<input type="text" name="custom_value" value="" hidden id="custom">
<button type="submit"
name="add-to-cart"
value="<?php echo esc_attr( $product->get_id() ); ?>"
onclick="jQuery('#custom').val(555)"
class="button alt single_add_to_cart_button">Заказать еще</button>
<button type="submit" name="add-to-cart"
value="<?php echo esc_attr( $product->get_id() ); ?>"
class="single_add_to_cart_button button alt">Оформить заказ</button>
</div>
add_filter( 'woocommerce_add_to_cart_redirect', 'stamp_skip_cart' );
function stamp_skip_cart( $redirect ) {
$cart_items = WC()->cart->get_cart();
foreach ($cart_items as $cart_item ) {
if ($cart_item['tmpost_data']['custom_value'] == 555){
return get_home_url();
}
else{
return wc_get_checkout_url();
}
}
}
add_filter('dynamic_sidebar_params', 'my_dynamic_sidebar_params');
function my_dynamic_sidebar_params( $params ) {
if (is_admin()){
return $params;
}
$widget_id = $params[0]['widget_id'];
if (get_field("widget_page", 'widget_'. $widget_id)){
$pages_id = get_field("widget_page", 'widget_'. $widget_id);
$pages_array = array('page' => $pages_id);
$params = array_merge($params, $pages_array);
if (is_singular()){
$id = get_the_ID();
$name = in_array($id, $params['page']);
}
}
if (get_field("widget_category", 'widget_'. $widget_id)){
$categories_id = get_field("widget_category", 'widget_'. $widget_id);
$categories_array = array('category' => $categories_id);
$params = array_merge($params, $categories_array);
if(is_category())
{
$id = get_the_category()[0]->cat_ID;
$name = in_array($id, $params['category']);
}
}
if(!$name){
return false;
};
return $params;
}