הוספת כפתור "קנה עכשיו" למוצרים
Tue May 18 2021 19:18:38 GMT+0000 (Coordinated Universal Time)
Saved by
@Shesek
/* Create Buy Now Button dynamically after Add To Cart button
function add_content_after_addtocart() {
// get the current post/product ID
$current_product_id = get_the_ID();
// get the product based on the ID
$product = wc_get_product( $current_product_id );
// get the "Checkout Page" URL
$checkout_url = WC()->cart->get_checkout_url();
// run only on simple products
if( $product->is_type( 'simple' ) ){
echo '<a href="'.$checkout_url.'?add-to-cart='.$current_product_id.'" class="buy-now button" style="background-color: #000000 !important; margin-right: 10px;">קנה עכשיו</a>';
//echo '<a href="'.$checkout_url.'" class="buy-now button">קנה עכשיו</a>';
}
}
add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart' );
content_copyCOPY
ניתן לעצב את הלחצן עם הקלאס buy-now button
ולמחוק את style="background-color: #000000 !important; margin-right: 10px;"
Comments