Советы / рекомендации

Добавить функцию пользовательского перенаправления на страницу благодарности woocommerce

add_action('after_setup_theme', 'woocommerce_support');
        function woocommerce_support()
        {
          add_theme_support('woocommerce');
        }


        add_filter('woocommerce_cart_item_name', 'add_excerpt_in_cart_item_name', 10, 3);
        function add_excerpt_in_cart_item_name($item_name,  $cart_item,  $cart_item_key)
        {
          $excerpt = wp_strip_all_tags(get_the_excerpt($cart_item['product_id']), true);
          $style = ' style="font-size:14px; line-height:normal;"';
          $excerpt_html = '
        <p name="short-description" class="product-description"' . $style . '>' . $excerpt . '</p>';

          return $item_name . $excerpt_html;
        }
        add_action( 'woocommerce_get_return_url', 'trueroman_redirect_to_thank_you_2', 90, 2 );
 
        function truemisha_redirect_to_thank_you_2( $thank_you_url, $order ) {
         
          // it would be nice to check the status of the order, do not redirect fake orders
          if( $order->has_status( 'failed' ) ) {
            return $thank_you_url;
          }
         
          return site_url( '/thanks?id='.$order->get_id() );
       
        }