WhatsApp Chat WooCommerce - https://solusipress.com/menambahkan-form-kontak-whatsapp-pada-halaman-produk-woocommerce/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'sp_woocommerce_contact_form' ); | |
function sp_woocommerce_contact_form() { | |
if( !is_admin() ) { | |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
if( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { | |
add_action( 'woocommerce_after_add_to_cart_button', 'sp_woo_add_contact_form_wa' ); | |
} | |
} | |
} | |
function sp_woo_add_contact_form_wa() { | |
global $product; | |
$name = $product->get_name(); | |
$sku = $product->get_sku(); | |
$purpose = 'Ingin bertanya untuk produk ' . $name . ' (SKU: ' . $sku . ')'; | |
echo '<div style="margin-top: 20px">'; | |
echo do_shortcode( '[sp_contact_wa phone="6281314997198" form_title="Pre-Sales Question" columns="5,4,3" purpose="' .$purpose. '"]' ); | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment