הוספת כפתור וואטסאפ לקנייה בלופ ארכיון מוצרים

PHOTO EMBED

Tue May 18 2021 16:57:04 GMT+0000 (Coordinated Universal Time)

Saved by @Shesek #whatsapp

/**
* WhatsApp button in product archive
*/
add_action('woocommerce_after_shop_loop_item', 'add_a_custom_button', 5 );
function add_a_custom_button() {
    global $product;

    // Not for variable and grouped products that doesn't have an "add to cart" button
    if( $product->is_type('variable') || $product->is_type('grouped') ) return;

    // Output the custom button linked to the product
    echo '<div style="margin-bottom:10px;">
        <a class="button custom-button" target="blank" href="https://api.whatsapp.com/send?phone=22222222&text=' . esc_attr( $product->get_title() ) . '">' . _('שלח ווטסאפ') . '</a>
    </div>';
}
content_copyCOPY

לשים לב לשנות את המספר בהודעה למטה ואת הטקסט שלה כמובן