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;
});
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
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.
Perfect, it works
Thank you very much Greg