Modify/Create a WordPress/WooCommerce Filter to add Text Over Image

Cancelado Publicado hace 7 años Pagado a la entrega
Cancelado Pagado a la entrega

Hey guys,

We are using a filter in our [login to view URL] file that adds a 'pre-order now' badge over the top of images on the [login to view URL] page. Works fantastic, however, we need it modified so that it shows the same badge over images on the store archive page.

Examples

This product has the pre-order now badge: [login to view URL]

This is the shop archive page, the badge doesnt show over the top left hand product image. We want it to show the 'pre-order now' badge like the single product page above: [login to view URL]

We would like our hook/filter modified so that we don't have to go editing other files needlessly. I have included the exact piece of code that adds this badge below.

add_filter( 'woocommerce_product_single_add_to_cart_text', 'vas_custom_cart_button_text' ); // < 2.1

add_filter( 'woocommerce_product_add_to_cart_text', 'vas_custom_cart_button_text' ); // < 2.1

function vas_custom_cart_button_text() {

global $product;

$preorder = get_post_meta( $product->id, '_wc_pre_orders_enabled', true );

if($preorder==false|| strtolower($preorder)!='yes')

{

$btn = 'Add to Cart';

}else{

$btn = 'Pre-Order Now';

}

return __( $btn, 'woocommerce' );

}

function vas_woocommerce_single_product_image_html( $sprintf, $post_id ) {

// make filter magic happen here...

$preorder = get_post_meta( $post_id, '_wc_pre_orders_enabled', true );

if($preorder==false|| strtolower($preorder)!='yes')

return $sprintf;

return '<span class="onsale is_pre">' . __( 'Pre-Order Now', 'woocommerce' ) . '</span>'. $sprintf;

};

add_filter( 'woocommerce_single_product_image_html', 'vas_woocommerce_single_product_image_html', 10, 2 );

PHP

Nº del proyecto: #11349101

Sobre el proyecto

4 propuestas Proyecto remoto Activo hace 7 años

4 freelancers están ofertando un promedio de £20 por este trabajo

Shripx

Hi there, Thanks for posting your project we are interested in your work & have vast experience in blog creation & customization. We will fix out the problems & that all will be done in few hour & you can che Más

£18 GBP en 1 día
(28 comentarios)
5.1