Support » Plugin: WPAdverts - Classifieds Plugin » Woocommerce Car

  • Resolved alexrick

    (@alexrick)


    Hola Greg

    thanks for your help

    After choosing a featured ad and publishing it, how can I redirect the customer to the cart page and not to the final checkout page?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    i understand you mean the redirect from Preview to WC Checkout? If so then you can change the redirect URL by adding the code below in theme functions.php file

    
    add_action( "wp_redirect", function( $url ) {
        $action = adverts_request("_adverts_action");
        $post_id = absint( adverts_request( "_post_id" ) );
        $link = get_permalink( wc_get_page_id( 'checkout' ) );
        if( $url == link && $action && $post_id ) {
            include_once dirname( __FILE__ ) . '/includes/class-wpadverts-wc-ad-manager.php';
            $ad_manager = new Wpadverts_Wc_Ad_Manager( $post_id );
            $featured = get_post_meta( $ad_manager->product->get_id(), '_advert_listing_featured', true );
            if( $featured ) {
                $url = "http://your/custom/link/";
            }
        }
        return $url;
    });
    
    Thread Starter alexrick

    (@alexrick)

    I added the following code (I already removed it because it does not work for me)

    add_action( “wp_redirect”, function( $url ) {
    $action = adverts_request(“_adverts_action”);
    $post_id = absint( adverts_request( “_post_id” ) );
    $link = get_permalink( wc_get_page_id( ‘checkout’ ) );
    if( $url == link && $action && $post_id ) {
    include_once dirname( __FILE__ ) . ‘/includes/class-wpadverts-wc-ad-manager.php’;
    $ad_manager = new Wpadverts_Wc_Ad_Manager( $post_id );
    $featured = get_post_meta( $ad_manager->product->get_id(), ‘_advert_listing_featured’, true );
    if( $featured ) {
    $url = “https://adflos.com/carrito/”;
    }
    }
    return $url;
    });

    I need to pre-visualize the featured ad, click on publish the ad redirect to the cart and not finish the purchase, because the cart sometimes has other products now the customer can be confused

    Que la redirección sea a: https://adflos.com/carrito/ y no a https://adflos.com/finalizar-compra

    Plugin Author Greg Winiarski

    (@gwin)

    The code i pasted should do exactly that.

    That being said what do you mean by “featured ad” and Ad that is marked as featured (that is displayed with a different background on Ads list) or an Ad that requires payment? The code does the first one.

    There is one typo in the code $url == link should be $url == $link.

    Thread Starter alexrick

    (@alexrick)

    Perfect, it works
    Thank you very much Greg

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocommerce Car’ is closed to new replies.