Skip to content

Instantly share code, notes, and snippets.

@yeriepiscesa
Last active April 22, 2020 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeriepiscesa/c23392785316311532774b7092c2a8bf to your computer and use it in GitHub Desktop.
Save yeriepiscesa/c23392785316311532774b7092c2a8bf to your computer and use it in GitHub Desktop.
<?php
add_action( 'wp_enqueue_scripts', 'solusipress_jquery_number' );
function solusipress_jquery_number() {
if( is_page( 'forminator-test' ) ) {
wp_enqueue_script( 'jquery-number', 'https://businessprofile.solusipress.com/wp-content/uploads/custom-css-js/18.js' );
/* load javascript dari Code JS yang sudah dibuat */
wp_enqueue_script( 'input-spinner', 'https://businessprofile.solusipress.com/wp-content/uploads/custom-css-js/105.js' );
}
}
add_action( 'wp_footer', 'solusipress_forminator_format_number' );
function solusipress_forminator_format_number() {
if( is_page( 'forminator-test' ) ) { ?>
<script type="text/javascript">
( function($){
/* ubah field number menjadi spinner */
wrap_spinner( 'forminator-field-number-1' );
$( '#calculation-1-field' ).hide();
$( '#calculation-1-field' ).parent().append( '<div id="total_html" style="font-weight:600;font-size:22px"></div>' );
set_total();
$( '#calculation-1-field' ).on( 'change', function(){
set_total();
} );
/* Kode untuk membungkus input number menjadi spinner */
function wrap_spinner( id ) {
$( '#'+id ).css( 'display','inline-block' )
.css( 'margin-top', '0px' )
.css( 'border', '1px solid #ccc' );
$( '#'+id ).attr( 'step', '1' )
.attr( 'readonly', 'readonly' );
$( '#'+id ).addClass( 'input-text qty text' );
$( '#'+id ).wrap( '<div class="quantity buttons_added"></div>' );
$( '#'+id ).parent().prepend( '<input type="button" value="-" class="minus">' );
$( '#'+id ).parent().append( '<input type="button" value="+" class="plus">' );
}
function set_total() {
var tot = $('#calculation-1-field').val();
$( '#total_html' ).html( 'Rp' + $.number( tot, 0, ',', '.' ) );
}
} )( jQuery );
</script><?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment