';
// icon for settings
echo '
';
// header
echo "" . __( 'Add Tip WooCommerce', 'atwoo-plugin' ) . "
";
// settings form
?>
Try Full version for added features such as to:
* Added defined amount to checkout
* Add Surcharge
* Enable for only certainly products
* Allow customer to use plus(+) and minus(-) buttons to increment amount
* Enable for shipping goods only and more...
'.__('Settings').'',
''.__('Support').''
);
return array_merge( $atwoo_plugin_links, $links );
}
// enable user to enable amount
add_action('woocommerce_before_checkout_form', 'atwoo_checkbox');
function atwoo_checkbox(){
global $woocommerce, $post, $wpdb;
$options = get_option( 'atwoo_settings' );
if ( $options['user_amount_alert'] == '1' ) {
// form and script
?>
'.$options['empty_message'].'
';
}
if ( !empty( $_POST['atwoo_amount'] ) && isset( $_POST['atwoo_amount'] ) ) {
update_option('atwoo_amount_up', $_POST['atwoo_amount'] );
echo ''.$options['success_message'].'
';
}
if ( ! isset( $_POST['atwoo_amount'] ) && empty( $_POST['atwoo_amount'] ) ) {
update_option('atwoo_amount_up', '0' );
}
}}
add_action( 'woocommerce_before_calculate_totals','woocommerce_custom_user_charge' );
function woocommerce_custom_user_charge() {
global $woocommerce, $post;
$options = get_option( 'atwoo_settings' );
if ( get_option('atwoo_amount_up') !== '0' ) {
if ( $options['user_amount_alert'] == '1' ) {
$fee_name = ''.$options['fee_name'].'';
$user_amount = get_option('atwoo_amount_up');
$user_charge = ( $user_amount );
$woocommerce->cart->add_fee( $fee_name, $user_charge, false, '' );
}}}