Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
Last active April 20, 2019 09:17
Show Gist options
  • Save yeriepiscesa/b217176b829273891ba85d0ddf7b912f to your computer and use it in GitHub Desktop.
Save yeriepiscesa/b217176b829273891ba85d0ddf7b912f to your computer and use it in GitHub Desktop.
<?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