File manager - Edit - /home/palg2351/public_html/klanaobsesiindonesia.com/wp-includes/Text/Diff/Engine/public.tar
Back
partials/sejoli-public-display.php 0000644 00000000555 15172717071 0013315 0 ustar 00 <?php /** * Provide a public-facing view for the plugin * * This file is used to markup the public-facing aspects of the plugin. * * @link https://ridwan-arifandi.com * @since 1.0.0 * * @package Sejoli * @subpackage Sejoli/public/partials */ ?> <!-- This file should primarily consist of HTML with a little bit of PHP. --> partials/coupon/autofill.php 0000644 00000004153 15172717071 0012231 0 ustar 00 <script type="text/javascript"> (function(){ 'use strict'; let coupon_checkout = '<?php echo $user_coupon; ?>', coupon_toggler, coupon_form, coupon_field, observer = new MutationObserver( function(mutations){ if( document.getElementById('sejoli-total-bayar') && document.getElementById('kode-diskon-form-toggle') && document.getElementById('kode-diskon-form') && document.getElementById('apply_coupon') ) { coupon_toggler = document.getElementById('kode-diskon-form-toggle'); coupon_form = document.getElementById('kode-diskon-form'); coupon_field = document.getElementById('apply_coupon'); if( '' !== coupon_checkout ) { coupon_toggler.style.display = 'none'; coupon_form.style.display = 'block'; coupon_field.value = coupon_checkout; document.getElementById('sejoli-submit-coupon').click(); } observer.disconnect(); } else if( document.getElementById('kode-diskon-form-toggle') && document.getElementById('kode-diskon-form') && document.getElementById('apply_coupon') ) { coupon_toggler = document.getElementById('kode-diskon-form-toggle'); coupon_form = document.getElementById('kode-diskon-form'); coupon_field = document.getElementById('apply_coupon'); if( '' !== coupon_checkout ) { coupon_toggler.style.display = 'none'; coupon_form.style.display = 'block'; coupon_field.value = coupon_checkout; document.getElementById('sejoli-submit-coupon').click(); } observer.disconnect(); } }); observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true}); })(); </script> partials/social-proof/iframe-js.php 0000644 00000007657 15172717071 0013375 0 ustar 00 (function(){ 'use strict'; let ssp_id = <?php echo $product->ID; ?>, ssp_css = document.createElement('link'), ssp_popup = document.createElement('div'), ssp_first_time = <?php echo $this->first_time; ?>, ssp_start, ssp_show_time = <?php echo $this->display_time; ?>, ssp_delay = <?php echo $this->delay_time; ?>, ssp_xhr = new XMLHttpRequest(), ssp_formdata, ssp_fade_in_c = 'sejolifadeInUp', ssp_fade_out_c = 'sejolifadeOutDown', ssp_show, ssp_position = '<?php echo $this->position; ?>'; ssp_popup.setAttribute('id', 'social-proof-container-<?php echo $product->ID; ?>'); ssp_popup.className = 'social-proof-container animated ' + ssp_position; ssp_popup.innerHTML = "<input type='hidden' id='social-proof-orders-" + ssp_id + "' class='social-proof-orders' name='social-proof-orders' value=''>" + "<section id='social-proof-holder' class='social-proof-holder'>" + "<figure class='buyer-photo'>" + "<img class='avatar' src='#' srcset='#' />" + "</figure>" + "<div class='buyer-detail'>" + "<div class='buyer-text'><?php echo $popup_text; ?></div>" + "<span class='order-text'>45 menit lalu</span>" + "</div>" + "</section>"; document.body.appendChild( ssp_popup ); let ssp_loaddata = function() { ssp_formdata = new FormData(); ssp_formdata.append('product_id', ssp_id); ssp_formdata.append('orders', ssp_popup.getElementsByClassName('social-proof-orders')[0].value ); ssp_xhr.open('POST', '<?php echo home_url('sejoli-social-proof-ajax/' . $product->ID ); ?>' ); ssp_xhr.onload = function() { if( ssp_xhr.status === 200 ) { let response = JSON.parse( ssp_xhr.responseText ) ; if( response.success ) { ssp_popup.getElementsByClassName('social-proof-orders')[0].value = response.data.orders; ssp_popup.getElementsByClassName('avatar')[0].src = response.data.avatar; ssp_popup.getElementsByClassName('avatar')[0].srcset = response.data.avatar; ssp_popup.getElementsByClassName('buyer-name')[0].innerHTML = response.data.name; ssp_popup.getElementsByClassName('product-name')[0].innerHTML = response.data.product; ssp_popup.getElementsByClassName('order-text')[0].innerHTML = response.data.time; setTimeout(function(){ ssp_fade_in(); }, 800); } else { console.log('error'); } } }; ssp_xhr.send( ssp_formdata ); }; let ssp_fade_in = function() { ssp_popup.classList.remove(ssp_fade_out_c); ssp_popup.classList.add(ssp_fade_in_c); ssp_show = setTimeout(function(){ ssp_fade_out(); }, ssp_show_time); }; let ssp_fade_out = function() { ssp_popup.classList.remove(ssp_fade_in_c); ssp_popup.classList.add(ssp_fade_out_c); setTimeout(function(){ ssp_loaddata(); }, ssp_show_time ) }; ssp_css.href = '<?php echo home_url('sejoli-social-proof-iframe/' . $product->ID . '/css'); ?>'; ssp_css.rel = 'stylesheet'; ssp_css.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(ssp_css); ssp_fade_in_c = ssp_position.includes('bottom') ? 'sejolifadeInUp' : 'sejolifadeInDown'; ssp_fade_out_c = ssp_position.includes('bottom') ? 'sejolifadeOutDown' : 'sejolifadeOutUp'; ssp_css.onload = function(){ console.log('load css completed'); ssp_start = setTimeout(function(){ ssp_loaddata(); }, ssp_first_time); }; })(); partials/social-proof/iframe.php 0000644 00000004174 15172717071 0012752 0 ustar 00 <?php /** * @since 1.5.0 * @since 1.5.1.1 Add conditional check for is_product_image_showed */ ?> <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title><?php echo $product->post_title; ?></title> <link rel='stylesheet'href='<?php echo SEJOLISA_URL; ?>public/css/sejoli-social-proof-iframe.css' type='text/css' media='all' /> </head> <body> <?php $user = wp_get_current_user(); $text = safe_str_replace( array( '{{buyer_name}}', '{{product_name}}' ), array( '<span class="buyer-name">' . $user->display_name . '</span>', '<span class="product-name">' . $product->post_title . '</span>' ), $this->popup_text ); $has_photo = ( $this->is_avatar_showed || $this->is_product_image_showed ) ? 'has-photo' : ''; ?> <div class="social-proof-container <?php echo $this->position; ?>"> <input type="hidden" name="social-proof-orders" id='social-proof-orders' value=""> <section id='social-proof-holder' class="social-proof-holder <?php echo $has_photo; ?> animated"> <?php if( $this->is_avatar_showed ) : ?> <figure class='buyer-photo'> <?php echo get_avatar($user); ?> </figure> <?php endif; ?> <div class="buyer-detail"> <div class="buyer-text"><?php echo $text; ?></div> <span class='order-text'>45 menit lalu</span> </div> </section> </div> <script type="text/javascript"> (function(){ 'use strict'; let ssc_iframe = parent.getElementById('sejoli-social-proof-iframe-<?php echo $product->ID; ?>'); console.log( ssc_iframe ); })(); </script> </body> </html> partials/social-proof/setup.php 0000644 00000006206 15172717071 0012645 0 ustar 00 <?php require_once( plugin_dir_path( __FILE__ ) ) . 'popup.php'; ?> <script type="text/javascript"> (function() { 'use strict'; let cssSProof = document.createElement('link'), ssp_popup = document.getElementById('social-proof-holder'), ssp_start, ssp_show, ssp_delay, ssp_fade_in, ssp_fade_out, ssp_xhr = new XMLHttpRequest(), ssp_loaddata, ssp_formdata, ssp_fade_in_c = 'fadeInUp', ssp_fade_out_c = 'fadeOutDown', ssp_avatar = ssp_popup.getElementsByClassName('avatar')[0]; ssp_loaddata = function() { ssp_formdata = new FormData(); ssp_formdata.append('product_id', sejoli_social_proof.product_id); ssp_formdata.append('orders', document.getElementById('social-proof-orders').value ); ssp_xhr.open('POST', sejoli_social_proof.ajax_url ); ssp_xhr.onload = function() { if( ssp_xhr.status === 200 ) { let response = JSON.parse( ssp_xhr.responseText ) ; if( response.success ) { document.getElementById('social-proof-orders').value = response.data.orders; if(typeof ssp_avatar !== "undefined") { ssp_popup.getElementsByClassName('avatar')[0].src = response.data.avatar; ssp_popup.getElementsByClassName('avatar')[0].srcset = response.data.avatar; } ssp_popup.getElementsByClassName('buyer-name')[0].innerHTML = response.data.name; ssp_popup.getElementsByClassName('product-name')[0].innerHTML = response.data.product; ssp_popup.getElementsByClassName('order-text')[0].innerHTML = response.data.time; setTimeout(function(){ ssp_fade_in(); }, 800); } else { console.log('error'); } } } ssp_xhr.send( ssp_formdata ); } ssp_fade_in = function() { ssp_popup.classList.remove(ssp_fade_out_c); ssp_popup.classList.add(ssp_fade_in_c); ssp_show = setTimeout(function(){ ssp_fade_out(); }, sejoli_social_proof.show_time); } ssp_fade_out = function() { ssp_popup.classList.remove(ssp_fade_in_c); ssp_popup.classList.add(ssp_fade_out_c); setTimeout(function(){ ssp_loaddata(); }, sejoli_social_proof.delay_time ) } cssSProof.href = sejoli_social_proof.main_css; cssSProof.rel = 'stylesheet'; cssSProof.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(cssSProof); ssp_fade_in_c = sejoli_social_proof.position.includes('bottom') ? 'fadeInUp' : 'fadeInDown'; ssp_fade_out_c = sejoli_social_proof.position.includes('bottom') ? 'fadeOutDown' : 'fadeOutUp'; cssSProof.onload = function(){ ssp_start = setTimeout(function(){ ssp_loaddata(); }, sejoli_social_proof.first_time); }; })(); </script> partials/social-proof/popup.php 0000644 00000002617 15172717071 0012652 0 ustar 00 <?php /** * @since 1.5.0 * @since 1.5.1.1 Add conditional check for is_product_image_showed */ defined( 'ABSPATH' ) || exit; global $post; $product = $post; $user = wp_get_current_user(); $text = safe_str_replace( array( '{{buyer_name}}', '{{product_name}}' ), array( '<span class="buyer-name">' . $user->display_name . '</span>', '<span class="product-name">' . $product->post_title . '</span>' ), $this->popup_text ); $has_photo = ( $this->is_avatar_showed || $this->is_product_image_showed ) ? 'has-photo' : ''; ?> <div class="social-proof-container <?php echo $this->position; ?>"> <input type="hidden" name="social-proof-orders" id='social-proof-orders' value=""> <section id='social-proof-holder' class="social-proof-holder <?php echo $has_photo; ?> animated"> <?php if( $this->is_avatar_showed || $this->is_product_image_showed ) : ?> <figure class='buyer-photo'> <?php echo get_avatar($user); ?> </figure> <?php endif; ?> <div class="buyer-detail"> <div class="buyer-text"><?php echo $text; ?></div> <span class='order-text'>45 menit lalu</span> </div> </section> </div> checkout.php 0000644 00000236316 15172717071 0007105 0 ustar 00 <?php namespace SejoliSA\Front; class Checkout { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Disable checkout page * @since 1.1.6 * @access protected * @var boolean */ protected $disable_checkout = false; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * If current page is loading page * @since 1.3.2 * @var boolean */ protected $is_loading_page = false; /** * If current page is thank you page * @since 1.3.2 * @var boolean */ protected $is_thankyou_page = false; /** * If current page is renew order page * @since 1.3.2 * @var boolean */ protected $is_renew_order_page = false; /** * Current order * @since 1.3.2 * @var false|array */ protected $current_order = false; /** * enqueue scripts * hooked via action wp_enqueue_scripts * * @return void */ public function enqueue_scripts() { global $post; // register css // wp_register_style( '', '',[],'','all'); wp_register_style( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.9/css/select2.min.css', [],'','all'); wp_register_style( 'google-font', 'https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap', [],'','all'); wp_register_style( 'semantic-ui', 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css',[],'2.4.1','all'); wp_register_style( 'flipclock', 'https://cdnjs.cloudflare.com/ajax/libs/flipclock/0.7.8/flipclock.min.css', [],'0.7.8','all'); if( is_singular(SEJOLI_PRODUCT_CPT) || $this->is_loading_page || $this->is_thankyou_page || sejolisa_verify_page( 'confirm' ) || sejolisa_verify_checkout_page( 'renew' ) ) : $style_url = SEJOLISA_URL.'public/css/sejoli-checkout.css'; if(isset($_GET['order_id'])) : $respond = sejolisa_get_order([ 'ID' => $_GET['order_id'] ]); $product_id = $respond['orders']['product_id']; else : $product_id = !empty($post) ? $post->ID : null; endif; $checkout_design = isset($_GET['design']) ? $_GET['design'] : ''; if (empty($checkout_design)) { $checkout_design = sejolisa_carbon_get_post_meta($product_id, 'checkout_design'); } $designs = apply_filters('sejoli/checkout/design/style', []); $style_url = isset($designs[$checkout_design]) ? $designs[$checkout_design] : $style_url; if (!empty($style_url)) : wp_register_style('sejoli-checkout', $style_url, [], $this->version, 'all'); endif; endif; // register js // wp_register_script( '', '',['jquery'],'',false); wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.9/js/select2.min.js',['jquery'],'',false); wp_register_script( 'blockUI', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js',['jquery'],'2.70',false); wp_register_script( 'jsrender', 'https://cdnjs.cloudflare.com/ajax/libs/jsrender/1.0.4/jsrender.min.js',['jquery'],'1.0.4',false); wp_register_script( 'semantic-ui', 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js',['jquery'],'2.4.1',false); wp_register_script( 'flipclock', 'https://cdnjs.cloudflare.com/ajax/libs/flipclock/0.7.8/flipclock.min.js',['jquery'],'0.7.8',false); wp_register_script( 'sejoli-public', SEJOLISA_URL. 'public/js/sejoli-public.js', ['jquery'], $this->version, false ); wp_register_script( 'sejoli-checkout', SEJOLISA_URL. 'public/js/sejoli-checkout.js', ['jquery'], $this->version,false); wp_register_script( 'sejoli-checkout-renew',SEJOLISA_URL. 'public/js/sejoli-checkout-renew.js', ['jquery', 'sejoli-checkout'], $this->version,false); $g_recaptcha = boolval(sejolisa_carbon_get_theme_option( 'sejoli_google_recaptcha_enabled' )); $g_recaptcha_checkout = boolval( sejolisa_carbon_get_theme_option( 'sejoli_google_recaptcha_checkout_page' ) ); $g_recaptcha_sitekey = esc_attr(sejolisa_carbon_get_theme_option( 'sejoli_google_recaptcha_sitekey' )); if( is_singular(SEJOLI_PRODUCT_CPT) ) : if( true === $g_recaptcha && !empty($g_recaptcha_sitekey) ) : wp_register_script( 'g-recaptcha', 'https://www.google.com/recaptcha/api.js?render='.$g_recaptcha_sitekey, [], null, true ); endif; if( true === $g_recaptcha && !empty($g_recaptcha_sitekey) && true === $g_recaptcha_checkout ) : wp_enqueue_script('g-recaptcha'); endif; wp_localize_script('sejoli-checkout', 'sejoli_checkout', [ 'g_recaptcha_enabled' => $g_recaptcha_checkout, 'g_recaptcha_sitekey' => $g_recaptcha_sitekey ]); endif; if ( sejolisa_is_checkout_page() ) : // load css wp_enqueue_style('select2'); wp_enqueue_style('google-font'); wp_enqueue_style('semantic-ui'); wp_enqueue_style('flipclock'); wp_enqueue_style('sejoli-checkout'); // load js wp_enqueue_script('jquery'); wp_enqueue_script('select2'); wp_enqueue_script('blockUI'); wp_enqueue_script('jsrender'); wp_enqueue_script('semantic-ui'); wp_enqueue_script('flipclock'); wp_enqueue_script('sejoli-checkout'); wp_localize_script('sejoli-checkout', 'sejoli_checkout', [ 'product_id' => get_the_ID(), 'order_id' => (isset($_GET['order_id'])) ? intval($_GET['order_id']) : null, 'ajax_url' => site_url('/'), 'ajax_nonce' => [ 'get_calculate' => wp_create_nonce('sejoli-checkout-ajax-get-calculate'), 'get_payment_gateway' => wp_create_nonce('sejoli-checkout-ajax-get-payment-gateway'), 'apply_coupon' => wp_create_nonce('sejoli-checkout-ajax-apply-coupon'), 'submit_checkout' => wp_create_nonce('sejoli-checkout-ajax-submit-checkout'), 'submit_login' => wp_create_nonce('sejoli-checkout-ajax-submit-login'), 'get_current_user' => wp_create_nonce('sejoli-checkout-ajax-get-current-user'), 'delete_coupon' => wp_create_nonce('sejoli-checkout-ajax-delete-coupon'), 'loading' => wp_create_nonce('sejoli-checkout-ajax-loading'), 'confirm' => wp_create_nonce('sejoli-checkout-ajax-confirm'), 'get_shipping_methods' => wp_create_nonce('sejoli-checkout-ajax-get-shipping-methods'), 'get_subdistrict' => wp_create_nonce('sejoli-checkout-ajax-get-subdistrict'), 'check_user_email' => wp_create_nonce('sejoli-checkout-ajax-check-user-email'), 'check_user_phone' => wp_create_nonce('sejoli-checkout-ajax-check-user-phone'), ], 'countdown_text' => [ 'jam' => __('Jam', 'sejoli'), 'menit' => __('Menit', 'sejoli'), 'detik' => __('Detik', 'sejoli'), ], 'district_select' => __('Silakan Ketik Nama Kecamatannya', 'sejoli'), 'affiliasi_oleh' => __('Affiliasi oleh', 'sejoli'), 'please_wait' => __('Please wait...', 'sejoli') ]); endif; if( sejolisa_verify_checkout_page('renew') ) : if( true === $g_recaptcha && !empty($g_recaptcha_sitekey) && true === $g_recaptcha_checkout ) : wp_enqueue_script('g-recaptcha'); endif; wp_enqueue_script('sejoli-checkout-renew'); wp_localize_script( 'sejoli-checkout-renew', 'sejoli_checkout_renew', array( 'order_id' => intval($_GET['order_id']), 'ajax_url' => site_url('/'), 'ajax_nonce' => [ 'get_calculate' => wp_create_nonce('sejoli-checkout-renew-ajax-get-calculate'), 'get_payment_gateway' => wp_create_nonce('sejoli-checkout-renew-ajax-get-payment-gateway'), 'apply_coupon' => wp_create_nonce('sejoli-checkout-renew-ajax-apply-coupon'), 'submit_checkout' => wp_create_nonce('sejoli-checkout-renew-ajax-submit-checkout'), 'delete_coupon' => wp_create_nonce('sejoli-checkout-renew-ajax-delete-coupon') ], 'g_recaptcha_enabled' => $g_recaptcha_checkout, 'g_recaptcha_sitekey' => $g_recaptcha_sitekey )); endif; } /** * Filter to add design style css * Hooked via filter sejoli/checkout/design/style, priority 10, 1 * @since 1.1.7 * @param array $designs * @return array */ public function sejoli_checkout_default_designs($designs) { $designs = [ 'version-2' => SEJOLISA_URL . 'public/css/v2/sejoli-checkout.css', 'modern' => SEJOLISA_URL . 'public/css/modern/sejoli-checkout.css', 'compact' => SEJOLISA_URL . 'public/css/compact/sejoli-checkout.css', 'less' => SEJOLISA_URL . 'public/css/less/sejoli-checkout.css', 'smart' => SEJOLISA_URL . 'public/css/smart/sejoli-checkout.css' ]; return $designs; } /** * Replace single product template with current sejoli * Hooked via filter single_template, priority 100 * @since 1.0.0 * @param string $template Single template file * @return string Modified single template file */ public function set_single_template( $template ) { global $post; $checkout_design = isset($_GET['design']) ? $_GET['design'] : ''; if($checkout_design): $design = $checkout_design; else: $design = sejolisa_carbon_get_post_meta($post->ID, 'checkout_design'); endif; if ( $post->post_type === 'sejoli-product' ) : // Tentukan file template berdasarkan jenis produk $file_name = ( $post->_product_type === 'digital' ) ? 'checkout.php' : 'checkout-fisik.php'; // Gunakan filter untuk mendapatkan template berdasarkan desain $template = apply_filters('sejoli/checkout/design/template', $template, $design, $file_name); endif; return $template; } /** * Filter to add design template * Hooked via filter sejoli/checkout/design/template, priority 10, 3 * @since 1.1.7 * @param array $designs * @return array */ public function sejoli_checkout_template_filter( $template, $design, $file_name ) { $default_template = SEJOLISA_DIR . 'template/checkout/' . $file_name; switch ($design) : case 'version-2': $template = file_exists(SEJOLISA_DIR . 'template/checkout/v2/' . $file_name) ? SEJOLISA_DIR . 'template/checkout/v2/' . $file_name : $default_template; break; case 'modern': $template = file_exists(SEJOLISA_DIR . 'template/checkout/modern/' . $file_name) ? SEJOLISA_DIR . 'template/checkout/modern/' . $file_name : $default_template; break; case 'compact': $template = file_exists(SEJOLISA_DIR . 'template/checkout/compact/' . $file_name) ? SEJOLISA_DIR . 'template/checkout/compact/' . $file_name : $default_template; break; case 'less': $template = file_exists(SEJOLISA_DIR . 'template/checkout/less/' . $file_name) ? SEJOLISA_DIR . 'template/checkout/less/' . $file_name : $default_template; break; case 'smart': $template = file_exists(SEJOLISA_DIR . 'template/checkout/smart/' . $file_name) ? SEJOLISA_DIR . 'template/checkout/smart/' . $file_name : $default_template; break; default: $template = file_exists(SEJOLISA_DIR . 'template/checkout/' . $file_name) ? SEJOLISA_DIR . 'template/checkout/' . $file_name : $default_template; break; endswitch; return $template; } /** * Display checkout header * @since 1.0.0 * @return void */ public function display_checkout_header() { sejoli_get_template_part( 'checkout/partials/header.php'); } /** * Display checkout footer * @since 1.0.0 * @return void */ public function display_checkout_footer() { sejoli_get_template_part( 'checkout/partials/footer.php'); } /** * Set checkout respond * @since 1.4.0 * @param array $respond * @param array $calculate * @param integer $quantity * @param string $coupon * @param boolean $is_coupon */ protected function set_checkout_respond( $respond, $calculate = array(), $quantity = 1, $coupon = NULL, $is_coupon = false ) { $prepare_calculate = array(); $request = wp_parse_args( $_POST,[ 'product_id' => 0, 'coupon' => NULL, 'quantity' => 1, 'type' => 'regular', 'payment_gateway' => 'manual', 'shipment' => NULL, 'variants' => [], 'wallet' => false, ]); if( isset( $respond['cart_detail'] ) && is_array( $respond['cart_detail'] ) ) : foreach ( $respond['cart_detail'] as $key => $value ) : if ( strpos($key, 'variant-') !== false ) : $total_price_variants = $value['raw_price'] * $quantity; $prepare_calculate['variants'][] = [ 'type' => ucwords($value['type']), 'label' => $value['label'], 'price' => ($total_price_variants > 0) ? sejolisa_price_format($total_price_variants) : '' ]; endif; endforeach; endif; $get_product_total = isset($respond['total']) ? $respond['total'] : 0; if ( isset( $respond['cart_detail']['shipment_fee'] ) ) : $get_product_total = ($respond['total'] - $respond['cart_detail']['shipment_fee']); elseif( isset( $respond['cart_detail']['transaction_fee'] ) ) : $get_product_total = ($respond['total'] - $respond['cart_detail']['transaction_fee']); elseif( isset( $respond['cart_detail']['shipment_fee'] ) && isset( $respond['cart_detail']['transaction_fee'] ) ) : $get_product_total = ($respond['total'] - $respond['cart_detail']['shipment_fee']) - $respond['cart_detail']['transaction_fee']; endif; if ( isset( $respond['cart_detail']['subscription'] ) ) : $prepare_calculate['subscription'] = $respond['cart_detail']['subscription']; endif; if ( isset( $respond['cart_detail']['transaction_fee'] ) ) : $prepare_calculate['transaction']['value'] = sejolisa_price_format( $respond['cart_detail']['transaction_fee'] ); endif; if ( isset( $respond['cart_detail']['shipment_fee'] ) ) : $prepare_calculate['shipment']['value'] = sejolisa_price_format( $respond['cart_detail']['shipment_fee'] ); endif; if ( isset( $respond['cart_detail']['ppn'] ) ) : $price_without_ppn = ($get_product_total / (1 + $respond['cart_detail']['ppn'] / 100)); $value_ppn = ($price_without_ppn * $respond['cart_detail']['ppn']) / 100; $prepare_calculate['ppn']['total'] = sejolisa_price_format( $value_ppn ); $prepare_calculate['ppn']['value'] = number_format($respond['cart_detail']['ppn'], 2, ',', ' '); endif; if ( isset( $respond['cart_detail']['markup_price_fee'] ) ) : $prepare_calculate['markup_price']['value'] = sejolisa_price_format( $respond['cart_detail']['markup_price_fee'] ); endif; if ( isset( $respond['cart_detail']['markup_price_label'] ) ) : $prepare_calculate['markup_price']['label'] = $respond['cart_detail']['markup_price_label']; endif; if ( isset( $respond['cart_detail']['coupon_value'] ) && !empty( $coupon ) ) : $getCoupon = sejolisa_get_coupon_by_code( $coupon ); $prepare_calculate['coupon']['code'] = $coupon; $prepare_calculate['coupon']['usage'] = $getCoupon['coupon']['usage']; $prepare_calculate['coupon']['limit_use'] = $getCoupon['coupon']['limit_use']; $prepare_calculate['coupon']['limit_date'] = $getCoupon['coupon']['limit_date']; $prepare_calculate['coupon']['status'] = $getCoupon['coupon']['status']; $prepare_calculate['coupon']['free_shipping'] = $getCoupon['coupon']['discount']['free_shipping']; if( true === boolval($getCoupon['coupon']['discount']['free_shipping']) ) : if ( isset( $respond['cart_detail']['shipment_fee'] ) ) : $setDiscountValue = $respond['cart_detail']['coupon_value'] + $respond['cart_detail']['shipment_fee']; else: $setDiscountValue = $respond['cart_detail']['coupon_value']; endif; $prepare_calculate['coupon']['disc_value_w_ongkir'] = sejolisa_price_format( $setDiscountValue ); endif; $prepare_calculate['coupon']['value'] = sejolisa_price_format( $respond['cart_detail']['coupon_value'] ); endif; // if ( isset( $respond['cart_detail']['wallet'] ) ) : // if ( isset( $respond['cart_detail']['shipment_fee'] ) ) : // $getWallet = $respond['cart_detail']['wallet'] + $respond['cart_detail']['shipment_fee']; // $prepare_calculate['wallet'] = '-' . sejolisa_price_format( $getWallet ); // else: // $prepare_calculate['wallet'] = '-' . sejolisa_price_format( $respond['cart_detail']['wallet'] ); // endif; // endif; if ( isset( $respond['cart_detail']['wallet'] ) ) : $prepare_calculate['wallet'] = sejolisa_price_format( $respond['cart_detail']['wallet']); endif; if( false !== $is_coupon ) : $calculate['data'] = array_merge( $calculate['data'], $prepare_calculate ); else : $calculate = array_merge( $calculate, $prepare_calculate ); endif; return $calculate; } /** * Set close template * Hooked via single_template, priority 9999 * @since 1.0.0 * @since 1.4.1 Add condition for only-group buy * @param string $template * @return string */ public function set_close_template($template) { global $post; if ( $post->post_type === 'sejoli-product' ) : if( true === $this->disable_checkout ) : $template = SEJOLISA_DIR . 'template/checkout/close.php'; else : $response = sejolisa_check_user_permission_by_product_group($post->ID); if(false === boolval($response['allow'])) : $template = SEJOLISA_DIR . 'template/checkout/restricted.php'; endif; endif; endif; return $template; } /** * Disable checkout page * Hooked via action template_redirect, priority 999 * @since 1.0.0 * @return void */ public function close_checkout() { if ( is_singular('sejoli-product') ) : global $post; $this->disable_checkout = sejolisa_is_product_closed($post->ID); endif; } /** * sejoli get calculate by ajax * hooked via action parse_request * * @return json */ public function get_calculate_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-get-calculate' ) ) : $request = wp_parse_args( $_POST,[ 'product_id' => 0, 'coupon' => NULL, 'quantity' => 1, 'type' => 'regular', 'payment_gateway' => 'manual', 'shipment' => NULL, 'markup_price' => NULL, 'variants' => [], 'wallet' => false, ]); $response = []; if ( $request['product_id'] > 0 ) : do_action( 'sejoli/frontend/checkout/calculate', $request ); $response['calculate'] = sejolisa_get_respond('calculate'); endif; wp_send_json( $response ); endif; } /** * Renew calculate renew by ajax * Hooked via action parse_request * @since 1.1.9 * @return json */ public function get_renew_calculate_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-renew-ajax-get-calculate' ) ) : $request = wp_parse_args( $_POST,[ 'order_id' => NULL, 'product_id' => NULL, 'coupon' => NULL, 'quantity' => 1, 'type' => 'regular', 'payment_gateway' => 'manual', 'shipment' => NULL, 'variants' => [], // 'wallet' => false, ]); $calculate = $response = []; if ( !empty( $request['product_id'] ) && !empty( $request['order_id'] ) ) : do_action('sejoli/checkout/calculate-renew', $request); $calculation = sejolisa_get_respond('total'); if( false !== $calculation['valid'] ) : $product = sejolisa_get_product( $request['product_id'] ); if ( is_a( $product, 'WP_Post' ) ) : $quantity = intval($calculation['detail']['quantity']); $product_price = $calculation['cart_detail']['subscription']['regular']['raw']; $product_total_price = $quantity * $product_price; $calculate = [ 'product' => [ 'id' => $product->ID, 'image' => get_the_post_thumbnail_url( $product->ID, 'full' ), 'title' => sprintf( __('Perpanjangan order INV %s<br /> Produk: %s', 'sejoli'), $request['order_id'], $product->post_title), 'price' => sejolisa_price_format( $product_price ), 'stock' => 0, 'variation' => NULL, 'quantity' => $quantity, 'subtotal' => sejolisa_price_format( $product_total_price ), 'fields' => $product->form ], 'affiliate' => $calculation['affiliate'], 'total' => sejolisa_coloring_unique_number( sejolisa_price_format( $calculation['total'] ) ), 'raw_total' => floatval( $calculation['total'] ) ]; if ( isset( $calculation['cart_detail']['subscription'] ) ) : $calculate['subscription'] = $calculation['cart_detail']['subscription']; endif; if ( isset( $calculation['cart_detail']['transaction_fee'] ) ) : $calculate['transaction']['value'] = sejolisa_price_format( $calculation['cart_detail']['transaction_fee'] ); endif; if ( isset( $calculation['cart_detail']['coupon_value'] ) ) : $calculate['coupon']['code'] = $request['coupon']; $calculate['coupon']['value'] = sejolisa_price_format( $calculation['cart_detail']['coupon_value'] ); endif; if ( isset( $calculation['cart_detail']['wallet'] ) ) : $calculate['wallet'] = sejolisa_price_format( $calculation['cart_detail']['wallet']); $calculate['transaction']['value'] = sejolisa_price_format( 0 ); endif; endif; endif; endif; wp_send_json( array( 'calculate' => $calculate ) ); endif; } /** * setup calculate data * hooked via action sejoli/frontend/checkout/calculate * * @return void */ public function calculate( $request ) { $calculate = []; $product = sejolisa_get_product( $request['product_id'] ); if ( is_a( $product, 'WP_Post' ) ) : do_action('sejoli/checkout/calculate', $request); $respond = sejolisa_get_respond('total'); $variation = ''; if ( !empty( $product->variants ) ) : $variation = $product->variants; endif; $donation_active = boolval( sejolisa_carbon_get_post_meta($product->ID, 'donation_active') ); if(false === $donation_active) : $quantity = intval($respond['detail']['quantity']); else : $quantity = isset($respond['detail']['quantity']) ? intval($respond['detail']['quantity']) : ''; endif; $coupon = (array_key_exists('coupon', $request)) ? $request['coupon'] : NULL; $product_price = $product->price; $product_total_price = floatval($quantity) * floatval($product->price); $product_format = sejolisa_carbon_get_post_meta( $product->ID, 'product_format' ); $product_type = sejolisa_carbon_get_post_meta( $product->ID, 'product_type' ); if($product_type === "digital" && $product_format === "main-product") : foreach ($product->bump_product as $key => $id_bump_product) : $product_bump_sales = sejolisa_get_product( $id_bump_product ); $order_parent = isset($request['order_parent_id']) ? $request['order_parent_id'] : null; if($product->subscription['signup']['fee'] > 0 && $order_parent <= 0) : $setProduct_price = $product->price + $product->subscription['signup']['fee']; else : $setProduct_price = $product->price; endif; $biaya_awal_bump_product = floatval(sejolisa_carbon_get_post_meta($product_bump_sales->ID, 'subscription_signup_fee')); if($coupon): $get_coupon = sejolisa_get_coupon_by_code($coupon); $discount_data = $get_coupon['coupon']['discount']; if($biaya_awal_bump_product > 0) : $set_bump_product_price = ($product_bump_sales->price + $biaya_awal_bump_product) - $setProduct_price; if('percentage' === $get_coupon['coupon']['discount']['type']) : $discount = $set_bump_product_price * ($quantity * $get_coupon['coupon']['discount']['value']) / 100; else : if('per_item' === $discount_data['usage']) : $discount = 0;//$quantity * $get_coupon['coupon']['discount']['value']; else : $discount = $discount_data['value']; endif; endif; if($respond['coupon_valid']): $bump_product_price = $set_bump_product_price - $discount; else: $bump_product_price = $set_bump_product_price; endif; else: $set_bump_product_price = $product_bump_sales->price - $setProduct_price; if('percentage' === $get_coupon['coupon']['discount']['type']) : $discount = $set_bump_product_price * ($quantity * $get_coupon['coupon']['discount']['value']) / 100; else : if('per_item' === $discount_data['usage']) : $discount = 0;//$quantity * $get_coupon['coupon']['discount']['value']; else : $discount = $discount_data['value']; endif; endif; if($respond['coupon_valid']): $bump_product_price = $set_bump_product_price - $discount; else: $bump_product_price = $set_bump_product_price; endif; endif; else: if($biaya_awal_bump_product > 0) : $bump_product_price = ($product_bump_sales->price + $biaya_awal_bump_product) - $setProduct_price; else : $bump_product_price = $product_bump_sales->price - $setProduct_price; endif; endif; $bump_product_total_price = floatval($quantity) * floatval($bump_product_price); $bump_sales_product[] = [ 'ID' => $product_bump_sales->ID, 'image' => get_the_post_thumbnail_url($product_bump_sales->ID,'full'), 'price' => sejolisa_price_format( $bump_product_price ), 'subtotal' => sejolisa_price_format( $bump_product_total_price ), 'enable_quantity' => sejolisa_carbon_get_post_meta( $product_bump_sales->ID, 'enable_quantity' ), 'product' => $product_bump_sales ]; endforeach; endif; // End check if product has bump product $calculate = [ 'product' => [ 'id' => $product->ID, 'image' => get_the_post_thumbnail_url($product->ID,'full'), 'title' => $product->post_title, 'price' => sejolisa_price_format( $product_price ), 'stock' => 0, 'variation' => $variation, 'quantity' => $quantity, 'subtotal' => sejolisa_price_format( $product_total_price ), 'fields' => $product->form, 'bump_sales' => (isset($bump_sales_product) ? $bump_sales_product : '') ], 'affiliate' => isset($respond['affiliate']) ? $respond['affiliate'] : '', 'total' => isset($respond['total']) ? sejolisa_coloring_unique_number( sejolisa_price_format( $respond['total'] ) ) : '', 'raw_total' => isset($respond['total']) ? floatval($respond['total']) : '' ]; if(true === $donation_active) : $calculate['product']['bump_sales'] = array(); $calculate['affiliate'] = isset($respond['affiliate']) ? $respond['affiliate'] : ''; $calculate['total'] = isset($respond['total']) ? sejolisa_coloring_unique_number( sejolisa_price_format( $respond['total'] ) ) : ''; $calculate['raw_total'] = isset($respond['total']) ? floatval($respond['total']) : ''; endif; $calculate = $this->set_checkout_respond($respond, $calculate, $quantity, $coupon); endif; sejolisa_set_respond( $calculate, 'calculate' ); } /** * sejoli check user email by ajax * hooked via action parse_request * * @return json */ public function check_user_email_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-check-user-email' ) ) : $request = wp_parse_args( $_POST,[ 'email' => '', ]); if ( is_email( $request['email'] ) ) : $user = sejolisa_get_user( $request['email'] ); if ( is_a($user,'WP_User') && $user->ID > 0 ) : wp_send_json_error([__('Alamat Email sudah terdaftar silahkan login menggunakan akun anda','sejoli')]); endif; endif; wp_send_json_success(); endif; } /** * sejoli check user phone by ajax * hooked via action parse_request * * @return json */ public function check_user_phone_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-check-user-phone' ) ) : $request = wp_parse_args( $_POST,[ 'phone' => '', ]); if ( ! empty( $request['phone'] ) ) : $user = sejolisa_get_user( $request['phone'] ); if ( is_a($user,'WP_User') && $user->ID > 0 ) : wp_send_json_error([__('No Handphone sudah terdaftar silahkan login menggunakan akun anda','sejoli')]); endif; endif; wp_send_json_success(); endif; } /** * sejoli get payment gateway by ajax * hooked via action parse_request * * @return json */ public function get_payment_gateway_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-get-payment-gateway' ) ) : $request = wp_parse_args( $_POST, []); $response = []; $response['payment_gateway'] = apply_filters('sejoli/frontend/checkout/payment-gateway', [], $request ); wp_send_json($response); endif; } /** * setup payment gateway data * hooked via filter sejoli/frontend/checkout/payment-gateway * * @return void */ public function payment_gateway( $payment_gateway, $request ) { $payment_gateway = []; $payment_options = sejolisa_get_payment_options(); $product_id = isset($request['product_id']) ? $request['product_id'] : null; $display_text_payment_channel = boolval(sejolisa_carbon_get_post_meta($product_id, 'display_text_payment_channel')); foreach ( $payment_options as $key => $value ) : if( \str_contains( strtolower( $key ), 'moota' ) || \str_contains( strtolower( $key ), 'duitku' ) ) { $label_check = __('(dicek otomatis)', 'sejoli'); } else { $label_check = ''; } $payment_gateway[] = [ 'id' => $key, 'title' => $value['label'], 'image' => $value['image'], 'display_payment' => $display_text_payment_channel, 'label_check' => $label_check ]; endforeach; return $payment_gateway; } /** * sejoli check coupon conditional limit ok, date ok * hooked via action parse_request * * @return json */ protected function couponLimitOkDateOk($coupon) { return $coupon['coupon']['limit_use'] > 0 && $coupon['coupon']['limit_date'] == null && $coupon['coupon']['usage'] < $coupon['coupon']['limit_use']; } /** * sejoli check coupon conditional limit ok, date by current date * hooked via action parse_request * * @return json */ protected function couponLimitOkDateOkUsageOk($coupon, $currentDateTime) { return $coupon['coupon']['limit_use'] > 0 && $coupon['coupon']['limit_date'] != null && $coupon['coupon']['usage'] < $coupon['coupon']['limit_use'] && $currentDateTime < $coupon['coupon']['limit_date']; } /** * sejoli check coupon conditional limit ok, date by current date * hooked via action parse_request * * @return json */ protected function couponLimitOkDateByCurrDate($coupon, $currentDateTime) { return $coupon['coupon']['limit_use'] == 0 && $coupon['coupon']['limit_date'] != null && $currentDateTime < $coupon['coupon']['limit_date']; } /** * sejoli check coupon conditional limit ok, status is active * hooked via action parse_request * * @return json */ protected function couponLimitOkStatusOk($coupon) { return $coupon['coupon']['limit_use'] == 0 && $coupon['coupon']['limit_date'] == null; } /** * sejoli coupon type * hooked via action parse_request * * @return json */ protected function couponCalculateType($request, $type) { return $request['calculate'] === $type; } /** * sejoli coupon valid * hooked via action parse_request * * @return json */ protected function couponValidActive($coupon) { return $coupon['valid'] && $coupon['coupon']['status'] == 'active'; } /** * sejoli apply coupon by ajax * hooked via action parse_request * * @return json */ public function apply_coupon_by_ajax() { $request = NULL; // Ordinary checkout if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-apply-coupon' ) ) : $request = wp_parse_args( $_POST,[ 'product_id' => 0, 'coupon' => NULL, 'quantity' => 1, 'type' => 'regular', 'payment_gateway' => 'manual', 'shipment' => NULL, 'calculate' => 'default' ]); elseif ( sejoli_ajax_verify_nonce( 'sejoli-checkout-renew-ajax-apply-coupon' ) ) : $request = wp_parse_args( $_POST,[ 'order_id' => 0, 'product_id' => 0, 'coupon' => NULL, 'quantity' => 1, 'calculate' => 'renew' ]); endif; if(is_array($request) && !empty($request['coupon']) ) : $coupon = sejolisa_get_coupon_by_code($request['coupon']); $renewal_coupon = isset($coupon['coupon']['rule']['renewal_coupon']) ? $coupon['coupon']['rule']['renewal_coupon'] : null; $currentDateTime = current_datetime()->format( 'Y-m-d H:i:s' ); if( $this->couponValidActive($coupon) && ( ($this->couponCalculateType($request, 'renew') && true === $renewal_coupon && $this->couponLimitOkDateOkUsageOk($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'renew') && true === $renewal_coupon && $this->couponLimitOkDateOk($coupon)) || ($this->couponCalculateType($request, 'renew') && true === $renewal_coupon && $this->couponLimitOkDateByCurrDate($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'renew') && true === $renewal_coupon && $this->couponLimitOkStatusOk($coupon)) || ($this->couponCalculateType($request, 'renew') && false === $renewal_coupon && $this->couponLimitOkDateOkUsageOk($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'renew') && false === $renewal_coupon && $this->couponLimitOkDateOk($coupon)) || ($this->couponCalculateType($request, 'renew') && false === $renewal_coupon && $this->couponLimitOkDateByCurrDate($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'renew') && false === $renewal_coupon && $this->couponLimitOkStatusOk($coupon)) || ($this->couponCalculateType($request, 'default') && false === $renewal_coupon && $this->couponLimitOkDateOkUsageOk($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'default') && false === $renewal_coupon && $this->couponLimitOkDateOk($coupon)) || ($this->couponCalculateType($request, 'default') && false === $renewal_coupon && $this->couponLimitOkDateByCurrDate($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'default') && false === $renewal_coupon && $this->couponLimitOkStatusOk($coupon)) || ($this->couponCalculateType($request, 'renew') && null === $renewal_coupon && $this->couponLimitOkDateOkUsageOk($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'renew') && null === $renewal_coupon && $this->couponLimitOkDateOk($coupon)) || ($this->couponCalculateType($request, 'renew') && null === $renewal_coupon && $this->couponLimitOkDateByCurrDate($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'renew') && null === $renewal_coupon && $this->couponLimitOkStatusOk($coupon)) || ($this->couponCalculateType($request, 'default') && null === $renewal_coupon && $this->couponLimitOkDateOkUsageOk($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'default') && null === $renewal_coupon && $this->couponLimitOkDateOk($coupon)) || ($this->couponCalculateType($request, 'default') && null === $renewal_coupon && $this->couponLimitOkDateByCurrDate($coupon, $currentDateTime)) || ($this->couponCalculateType($request, 'default') && null === $renewal_coupon && $this->couponLimitOkStatusOk($coupon)) ) ): do_action('sejoli/frontend/checkout/apply-coupon', $coupon, $request); $response = sejolisa_get_respond('apply-coupon'); elseif($coupon['valid'] && $coupon['coupon']['status'] == 'inactive') : $response = [ 'valid' => false, 'messages' => [__('Kupon tidak aktif', 'sejoli')] ]; elseif($coupon['valid'] && $coupon['coupon']['limit_use'] > 0 && $coupon['coupon']['limit_date'] == null && $coupon['coupon']['usage'] >= $coupon['coupon']['limit_use'] && $coupon['coupon']['status'] == 'active') : $response = [ 'valid' => false, 'messages' => [__('Batas penggunaan kupon sudah mencapai batas')] ]; elseif($coupon['valid'] && $coupon['coupon']['limit_use'] >= 0 && $coupon['coupon']['limit_date'] != null && $currentDateTime > $coupon['coupon']['limit_date'] && $coupon['coupon']['status'] == 'active') : $response = [ 'valid' => false, 'messages' => [__('Batas penggunaan kupon sudah berakhir', 'sejoli')] ]; elseif($coupon['valid'] && $coupon['coupon']['limit_use'] > 0 && $coupon['coupon']['limit_date'] != null && $coupon['coupon']['usage'] >= $coupon['coupon']['limit_use'] && $currentDateTime > $coupon['coupon']['limit_date'] && $coupon['coupon']['status'] == 'active') : $response = [ 'valid' => false, 'messages' => [__('Batas penggunaan kupon sudah mencapai batas dan sudah berakhir', 'sejoli')] ]; elseif($coupon['valid'] && $request['calculate'] === 'default' && $renewal_coupon) : $response = [ 'valid' => false, 'messages' => [__('Kode kupon ini hanya untuk perpanjangan langganan', 'sejoli')] ]; else : $response = [ 'valid' => false, 'messages' => [__('Kode kupon tidak valid', 'sejoli')] ]; endif; wp_send_json($response); endif; if(is_array($request) && empty($request['coupon']) ) : $response = [ 'valid' => false, 'messages' => [__('Kode kupon belum diisi!', 'sejoli')] ]; wp_send_json($response); endif; } /** * sejoli apply coupon * hooked via action sejoli/frontend/checkout/apply-coupon * * @return json */ public function apply_coupon( $coupon, $request ) { if(!isset($request['calculate']) || 'default' === $request['calculate']) : do_action('sejoli/checkout/calculate', $request); else : do_action('sejoli/checkout/calculate-renew', $request); endif; $respond = sejolisa_get_respond('total'); if ( isset( $respond['messages']['warning'] ) && is_array( $respond['messages']['warning'] ) && 0 < count( $respond['messages']['warning'] ) && empty( $respond['messages']['info'] ) ) : $respond = [ 'valid' => false, 'messages' => $respond['messages']['warning'], ]; sejolisa_set_respond($respond, 'apply-coupon'); else: $product = sejolisa_get_product( $request['product_id'] ); $variant_price = 0; foreach ( $respond['cart_detail'] as $key => $value ) : if ( strpos($key, 'variant-') !== false ) : $variant_price = $value['raw_price']; endif; endforeach; if($product->subscription['signup']['fee'] > 0 && 'renew' !== $request['calculate']): $setProduct_price = $product->price + $product->subscription['signup']['fee']; else: $setProduct_price = $product->price; endif; $discount_value = apply_filters('sejoli/coupon/value', $coupon['coupon']['discount']['value'], $setProduct_price, $coupon['coupon'], $request); if ( $coupon['coupon']['discount']['type'] === 'percentage' ) : // $discount_value = ( $discount_value / 100 ) * $product->price; $discount_value = $discount_value; else: $discount_value = $discount_value; endif; $discount_data = $coupon['coupon']['discount']; $thumbnail_url = get_the_post_thumbnail_url($product->ID,'full'); if ( $thumbnail_url === false ) : $thumbnail_url = ''; endif; $quantity = intval($respond['detail']['quantity']); $product_price = $product->price; $shipment_fee = isset($respond['cart_detail']['shipment_fee']) ? $respond['cart_detail']['shipment_fee'] : 0; $transaction_fee = isset($respond['cart_detail']['transaction_fee']) ? $respond['cart_detail']['transaction_fee'] : 0; $product_total_price = $quantity * $product_price; if($variant_price > 0){ $checkTotal = $product->price + $shipment_fee + $variant_price; } else { if($shipment_fee > 0){ $checkTotal = $product->price + $shipment_fee; } else { $checkTotal = $product->price; } } if($discount_value == $checkTotal){ if( $coupon['coupon']['discount']['value'] == 100 ){ $respond['total'] = $respond['total'] - $transaction_fee; } else { if($shipment_fee > 0){ $respond['total'] = $respond['total']; } else { $respond['total'] = $respond['total']; } } } else { $respond['total'] = $respond['total']; } $product_format = sejolisa_carbon_get_post_meta( $product->ID, 'product_format' ); $product_type = sejolisa_carbon_get_post_meta( $product->ID, 'product_type' ); if($product_type === "digital" && $product_format === "main-product") : foreach ($product->bump_product as $key => $id_bump_product) : $product_bump_sales = sejolisa_get_product( $id_bump_product ); $biaya_awal_bump_product = floatval(sejolisa_carbon_get_post_meta($product_bump_sales->ID, 'subscription_signup_fee')); if($biaya_awal_bump_product > 0) : $set_bump_product_price = ($product_bump_sales->price + $biaya_awal_bump_product) - $setProduct_price; if('percentage' === $coupon['coupon']['discount']['type']) : $discount = $set_bump_product_price * ($quantity * $coupon['coupon']['discount']['value']) / 100; else : if('per_item' === $discount_data['usage']) : $discount = 0;//$quantity * $coupon['coupon']['discount']['value']; else : $discount = $discount_data['value']; endif; endif; if($respond['coupon_valid']): $bump_product_price = $set_bump_product_price - $discount; else: $bump_product_price = $set_bump_product_price; endif; else: $set_bump_product_price = $product_bump_sales->price - $setProduct_price; if('percentage' === $coupon['coupon']['discount']['type']) : $discount = $set_bump_product_price * ($quantity * $coupon['coupon']['discount']['value']) / 100; else : if('per_item' === $discount_data['usage']) : $discount = 0;//$quantity * $coupon['coupon']['discount']['value']; else : $discount = $discount_data['value']; endif; endif; if($respond['coupon_valid']): $bump_product_price = $set_bump_product_price - $discount; else: $bump_product_price = $set_bump_product_price; endif; endif; $bump_product_total_price = floatval($quantity) * floatval($bump_product_price); $bump_sales_product[] = [ 'ID' => $product_bump_sales->ID, 'image' => get_the_post_thumbnail_url($product_bump_sales->ID,'full'), 'price' => sejolisa_price_format( $bump_product_price ), 'subtotal' => sejolisa_price_format( $bump_product_total_price ), 'enable_quantity' => sejolisa_carbon_get_post_meta( $product_bump_sales->ID, 'enable_quantity' ), 'product' => $product_bump_sales ]; endforeach; endif; if(isset($request['main_product_id'])): $main_bump_product = sejolisa_get_product( $request['main_product_id'] ); if($product_type === "digital" && $product_format === "bump-product") : foreach ($main_bump_product->bump_product as $key => $id_bump_product) : if($main_bump_product->subscription['signup']['fee'] > 0 && 'renew' !== $request['calculate']): $setProduct_price = $main_bump_product->price + $main_bump_product->subscription['signup']['fee']; else: $setProduct_price = $main_bump_product->price; endif; $product_bump_sales = sejolisa_get_product( $id_bump_product ); $biaya_awal_bump_product = floatval(sejolisa_carbon_get_post_meta($product_bump_sales->ID, 'subscription_signup_fee')); if($biaya_awal_bump_product > 0) : $set_bump_product_price = ($product_bump_sales->price + $biaya_awal_bump_product) - $setProduct_price; if('percentage' === $coupon['coupon']['discount']['type']) : $discount = $set_bump_product_price * ($quantity * $coupon['coupon']['discount']['value']) / 100; else : if('per_item' === $discount_data['usage']) : $discount = 0;//$quantity * $coupon['coupon']['discount']['value']; else : $discount = $discount_data['value']; endif; endif; if($respond['coupon_valid']): $bump_product_price = $set_bump_product_price - $discount; else: $bump_product_price = $set_bump_product_price; endif; else: $set_bump_product_price = $product_bump_sales->price - $setProduct_price; if('percentage' === $coupon['coupon']['discount']['type']) : $discount = $set_bump_product_price * ($quantity * $coupon['coupon']['discount']['value']) / 100; else : if('per_item' === $discount_data['usage']) : $discount = 0;//$quantity * $coupon['coupon']['discount']['value']; else : $discount = $discount_data['value']; endif; endif; if($respond['coupon_valid']): $bump_product_price = $set_bump_product_price - $discount; else: $bump_product_price = $set_bump_product_price; endif; endif; $bump_product_total_price = floatval($quantity) * floatval($bump_product_price); $bump_sales_product[] = [ 'ID' => $product_bump_sales->ID, 'image' => get_the_post_thumbnail_url($product_bump_sales->ID,'full'), 'price' => sejolisa_price_format( $bump_product_price ), 'subtotal' => sejolisa_price_format( $bump_product_total_price ), 'enable_quantity' => sejolisa_carbon_get_post_meta( $product_bump_sales->ID, 'enable_quantity' ), 'product' => $product_bump_sales ]; endforeach; endif; endif; $calculate = [ 'valid' => true, 'messages' => $respond['messages']['info'], 'data' => [ 'affiliate' => $respond['affiliate'], 'product' => [ 'id' => $product->ID, 'image' => $thumbnail_url, 'title' => (!isset($request['calculate']) || 'default' === $request['calculate']) ? $product->post_title : sprintf( __('Perpanjangan order INV %s<br /> Produk: %s', 'sejoli'), $request['order_id'], $product->post_title), 'price' => sejolisa_price_format( $product_price ), 'quantity' => $quantity, 'subtotal' => sejolisa_price_format( $product_total_price ), 'bump_sales' => (isset($bump_sales_product) ? $bump_sales_product : '') ], 'coupon' => [ 'code' => $coupon['coupon']['code'], 'type' => $coupon['coupon']['discount']['type'], 'nominal' => $coupon['coupon']['discount']['value'], 'value' => sejolisa_price_format($discount_value), 'limit_use' => $coupon['coupon']['limit_use'], 'usage' => $coupon['coupon']['usage'], 'limit_date'=> $coupon['coupon']['limit_date'], 'status' => $coupon['coupon']['status'], ], 'total' => sejolisa_coloring_unique_number( sejolisa_price_format( $respond['total'] ) ), 'raw_total' => floatval( $respond['total'] ) ] ]; $calculate = $this->set_checkout_respond($respond, $calculate, $quantity, $request['coupon'], true); sejolisa_set_respond($calculate, 'apply-coupon'); endif; } /** * sejoli submit checkout by ajax * hooked via action parse_request * @since 1.0.0 * @return json */ public function submit_checkout_by_ajax() { $request = NULL; if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-submit-checkout' ) ) : $request = wp_parse_args($_POST,[ 'user_id' => NULL, 'affiliate_id' => NULL, 'coupon' => NULL, 'payment_gateway' => 'manual', 'quantity' => 1, 'user_email' => NULL, 'user_name' => NULL, 'user_password' => NULL, 'postal_code' => NULL, 'user_phone' => NULL, 'district_id' => NULL, 'district_name' => NULL, 'shipment' => NULL, 'wallet' => NULL, 'product_id' => 0, 'variants' => [], 'other' => [], 'recaptcha_response' => '', ]); $checkout_type = 'default'; elseif ( sejoli_ajax_verify_nonce( 'sejoli-checkout-renew-ajax-submit-checkout' ) ) : $request = wp_parse_args($_POST,[ 'user_id' => NULL, 'affiliate_id' => NULL, 'coupon' => NULL, 'wallet' => NULL, 'payment_gateway' => 'manual', 'quantity' => 1, 'product_id' => 0, 'order_id' => 0, 'recaptcha_response' => '', ]); $checkout_type = 'renew'; endif; if(is_array($request)) : $current_user = wp_get_current_user(); if ( isset( $current_user->ID ) && $current_user->ID > 0 ) : $request['user_id'] = $current_user->ID; endif; if('default' === $checkout_type) : do_action('sejoli/checkout/do', $request); else : do_action('sejoli/checkout/renew', $request); endif; $order = sejolisa_get_respond('order'); $checkout = sejolisa_get_respond('checkout'); if(false === $checkout['valid']) : $response = [ 'valid' => false, 'messages' => $checkout['messages']['error'], ]; elseif(false == $order['valid']) : $response = [ 'valid' => false, 'messages' => $order['messages']['error'], ]; else: $d_order = $order['order']; $messages = [sprintf( __('Order created successfully. Order ID #%s', 'sejoli'), $d_order['ID'] )]; if(0 < count($order['messages']['warning'])) : foreach($order['messages']['warning'] as $message) : $messages[] = $message; endforeach; endif; if(0 < count($order['messages']['info'])) : foreach($order['messages']['info'] as $message) : $messages[] = $message; endforeach; endif; $fast_checkout = boolval( carbon_get_post_meta($request['product_id'], 'fast_checkout_option') ); if( false !== $fast_checkout ) : $response = [ 'valid' => true, 'messages' => $messages, 'redirect_link' => site_url('checkout/thank-you?order_id='.$d_order['ID']), 'data' => [ 'order' => $d_order ] ]; else: $response = [ 'valid' => true, 'messages' => $messages, 'redirect_link' => site_url('checkout/loading?order_id='.$d_order['ID']), 'data' => [ 'order' => $d_order ] ]; endif; $fb_conversion_active = boolval(sejolisa_carbon_get_post_meta($d_order['product_id'], 'fb_conversion_active')); $fb_eventString = esc_attr(sejolisa_carbon_get_post_meta($d_order['product_id'], 'fb_conversion_event_submit_checkout_button')); if(true === $fb_conversion_active && !empty($fb_eventString)) : sejoli_facebook_tracker( $d_order, $fb_eventString ); endif; $tiktok_conversion_active = boolval(sejolisa_carbon_get_post_meta($d_order['product_id'], 'tiktok_conversion_active')); $tiktok_eventString = esc_attr(sejolisa_carbon_get_post_meta($d_order['product_id'], 'tiktok_conversion_event_submit_checkout_button')); if(true === $tiktok_conversion_active && !empty($tiktok_eventString)) : sejoli_tiktok_tracker( $d_order, $tiktok_eventString ); endif; endif; wp_send_json($response); endif; } /** * sejoli submit login by ajax * hooked via action parse_request * * @return json */ public function submit_login_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-submit-login' ) ) : $request = wp_parse_args($_POST,[ 'login_email' => NULL, 'login_password' => NULL, ]); $errors = []; if ( empty( $request['login_email'] ) ) : $errors[] = __('Alamat email wajib diisi'); endif; if ( empty( $request['login_password'] ) ) : $errors[] = __('Password wajib diisi'); endif; if ( empty( $errors ) ) : $credentials = array( 'user_login' => $request['login_email'], 'user_password' => $request['login_password'], 'remember' => 1, ); $secure_cookie = apply_filters( 'secure_signon_cookie', '', $credentials ); $user = wp_authenticate( $credentials['user_login'], $credentials['user_password'] ); if ( !is_wp_error( $user ) ) : wp_set_auth_cookie( $user->ID, $credentials['remember'], $secure_cookie ); wp_send_json_success(['Login success']); else: $errors[] = __('Alamat Email atau Password salah'); endif; endif; wp_send_json_error($errors); endif; } /** * sejoli get current user by ajax * hooked via action parse_request * * @return json */ public function get_current_user_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-get-current-user' ) ) : $request = wp_parse_args( $_POST, []); $response = []; $response['current_user'] = apply_filters('sejoli/frontend/checkout/current-user', [], $request ); wp_send_json($response); endif; } /** * setup current user data * hooked via filter sejoli/frontend/checkout/current-user * * @return void */ public function current_user( $current_user, $request ) { $current_user = []; $user = wp_get_current_user(); if ( $user->ID > 0 ) : if ( !empty( $user->first_name ) ) : $name = $user->first_name; else: $name = $user->display_name; endif; $address = $user->_address; $subdistrict = $user->_destination_name; $subdistrict_id = $user->_destination; if (!empty($subdistrict)) : $district = sejolisa_get_district_options_by_ids($subdistrict); // pastikan ini array if (!empty($district['results'])) : // Cari yang cocok berdasarkan ID foreach ($district['results'] as $item) { if ((string)$item['id'] === (string)$subdistrict_id) { $subdistrict = $item; break; } } endif; endif; $current_user = [ 'id' => $user->ID, 'name' => $name, 'email' => $user->user_email, 'phone' => $user->_phone, 'postal_code' => $user->_postal_code, 'address' => $address, 'subdistrict' => $subdistrict, ]; endif; return $current_user; } /** * sejoli delete coupon by ajax * hooked via action parse_request * * @return json */ public function delete_coupon_by_ajax() { $request = NULL; // Ordinary order if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-delete-coupon' ) ) : $request = wp_parse_args( $_POST,[ 'product_id' => 0, 'coupon' => NULL, 'quantity' => 1, 'type' => 'regular', 'payment_gateway' => 'manual', 'calculate' => 'default' ]); // Renew order elseif ( sejoli_ajax_verify_nonce( 'sejoli-checkout-renew-ajax-delete-coupon' ) ) : $request = wp_parse_args( $_POST,[ 'order_id' => 0, 'product_id' => 0, 'coupon' => NULL, 'quantity' => 1, 'type' => 'regular', 'payment_gateway' => 'manual', 'calculate' => 'renew' ]); endif; if(is_array($request)) : $request['coupon'] = NULL; if ( intval($request['product_id']) > 0 ) : do_action('sejoli/frontend/checkout/delete-coupon', $request); $response = sejolisa_get_respond('delete-coupon'); wp_send_json($response); endif; $response = [ 'valid' => false, 'messages' => [__('Hapus kupon gagal')] ]; wp_send_json($response); endif; } /** * sejoli delete coupon * hooked via action sejoli/frontend/checkout/delete-coupon * * @return json */ public function delete_coupon( $request ) { if(!isset($request['calculate']) || 'default' === $request['calculate']) : do_action('sejoli/checkout/calculate', $request); else : do_action('sejoli/checkout/calculate-renew', $request); endif; $respond = sejolisa_get_respond('total'); $product = sejolisa_get_product( $request['product_id'] ); $quantity = intval($respond['detail']['quantity']); $product_price = isset($respond['cart_detail']['subscription']['regular']['raw']) ? $respond['cart_detail']['subscription']['regular']['raw'] : $product->price; $product_total_price = $quantity * $product_price; $product = sejolisa_get_product( $request['product_id'] ); if($product->subscription['signup']['fee'] > 0 && 'renew' !== $request['calculate']): $setProduct_price = $product->price + $product->subscription['signup']['fee']; else: $setProduct_price = $product->price; endif; $product_format = sejolisa_carbon_get_post_meta( $product->ID, 'product_format' ); $product_type = sejolisa_carbon_get_post_meta( $product->ID, 'product_type' ); if($product_type === "digital" && $product_format === "main-product") : foreach ($product->bump_product as $key => $id_bump_product) : $product_bump_sales = sejolisa_get_product( $id_bump_product ); $biaya_awal_bump_product = floatval(sejolisa_carbon_get_post_meta($product_bump_sales->ID, 'subscription_signup_fee')); if($biaya_awal_bump_product > 0) : $set_bump_product_price = ($product_bump_sales->price + $biaya_awal_bump_product) - $setProduct_price; $bump_product_price = $set_bump_product_price; else: $set_bump_product_price = $product_bump_sales->price - $setProduct_price; $bump_product_price = $set_bump_product_price; endif; $bump_product_total_price = floatval($quantity) * floatval($bump_product_price); $bump_sales_product[] = [ 'ID' => $product_bump_sales->ID, 'image' => get_the_post_thumbnail_url($product_bump_sales->ID,'full'), 'price' => sejolisa_price_format( $bump_product_price ), 'subtotal' => sejolisa_price_format( $bump_product_total_price ), 'enable_quantity' => sejolisa_carbon_get_post_meta( $product_bump_sales->ID, 'enable_quantity' ), 'product' => $product_bump_sales ]; endforeach; endif; if(isset($request['main_product_id'])): $main_bump_product = sejolisa_get_product( $request['main_product_id'] ); if($product_type === "digital" && $product_format === "bump-product") : foreach ($main_bump_product->bump_product as $key => $id_bump_product) : if($main_bump_product->subscription['signup']['fee'] > 0 && 'renew' !== $request['calculate']): $setProduct_price = $main_bump_product->price + $main_bump_product->subscription['signup']['fee']; else: $setProduct_price = $main_bump_product->price; endif; $product_bump_sales = sejolisa_get_product( $id_bump_product ); $biaya_awal_bump_product = floatval(sejolisa_carbon_get_post_meta($product_bump_sales->ID, 'subscription_signup_fee')); if($biaya_awal_bump_product > 0) : $set_bump_product_price = ($product_bump_sales->price + $biaya_awal_bump_product) - $setProduct_price; $bump_product_price = $set_bump_product_price; else: $set_bump_product_price = $product_bump_sales->price - $setProduct_price; $bump_product_price = $set_bump_product_price; endif; $bump_product_total_price = floatval($quantity) * floatval($bump_product_price); $bump_sales_product[] = [ 'ID' => $product_bump_sales->ID, 'image' => get_the_post_thumbnail_url($product_bump_sales->ID,'full'), 'price' => sejolisa_price_format( $bump_product_price ), 'subtotal' => sejolisa_price_format( $bump_product_total_price ), 'enable_quantity' => sejolisa_carbon_get_post_meta( $product_bump_sales->ID, 'enable_quantity' ), 'product' => $product_bump_sales ]; endforeach; endif; endif; $calculate = [ 'valid' => true, 'messages' => [__('Hapus kupon berhasil')], 'data' => [ 'product' => [ 'id' => $product->ID, 'image' => get_the_post_thumbnail_url($product->ID,'full'), 'title' => (!isset($request['calculate']) || 'default' === $request['calculate']) ? $product->post_title : sprintf( __('Perpanjangan order INV %s<br /> Produk: %s', 'sejoli'), $request['order_id'], $product->post_title), 'price' => sejolisa_price_format( $product_price ), 'quantity' => $quantity, 'subtotal' => sejolisa_price_format( $product_total_price ), 'bump_sales' => (isset($bump_sales_product) ? $bump_sales_product : '') ], 'total' => sejolisa_coloring_unique_number( sejolisa_price_format( $respond['total'] ) ) ] ]; $calculate = $this->set_checkout_respond($respond, $calculate, $quantity, '', true); sejolisa_set_respond($calculate, 'delete-coupon'); } /** * Register custom query variables * Hooked via filter parse_query, priority 999 * @since 1.0.0 * @param array $vars [description] * @return array */ public function custom_query_vars( $vars ) { $vars[] = "sejolisa_checkout_page"; $vars[] = "sejolisa_checkout_id"; $vars[] = 'order_id'; return $vars; } /** * Check requested page * Hooked via action parse_request, priority 999 * @since 1.3.2 * @return void */ public function check_requested_page() { global $sejolisa; if( sejolisa_verify_checkout_page('loading') ) : $this->is_loading_page = true; $this->current_order = $sejolisa['order']; elseif( sejolisa_verify_checkout_page( 'thank-you' ) ) : $this->is_thankyou_page = true; $this->current_order = $sejolisa['order']; elseif( sejolisa_verify_checkout_page('renew') ) : $this->is_renew_order_page = true; $this->current_order = $sejolisa['order']; endif; // __print_debug(array( // 'loading' => $this->is_loading_page, // 'regular' => $this->is_regular_page, // 'renew_order' => $this->is_renew_order_page, // 'order' => $this->current_order // )); // exit; } /** * Check request template page * Hooked via action template_redirect, priority 800 * @since 1.3.2 * @return void */ public function check_requested_template() { global $sejolisa; if( $this->is_thankyou_page && $this->current_order ) : do_action('sejoli/thank-you/render', $this->current_order); endif; } /** * Set template file based on request * Hooked via filter template_include, priority 999 * @since 1.3.2 * @since 1.5.3 Add expired renew template * @param string $template_file * @return string */ public function set_template_file($template_file) { global $post; if($this->is_loading_page) : $template_file = SEJOLISA_DIR . 'template/checkout/loading.php'; elseif($this->is_thankyou_page) : $payment_gateway = $this->current_order['payment_gateway']; $grand_total = floatval($this->current_order['grand_total']); if(isset($_GET['order_id'])) { $respond = sejolisa_get_order([ 'ID' => $_GET['order_id'] ]); $product_id = $respond['orders']['product_id']; } else { $product_id = $post->ID; } $checkout_design = isset($_GET['design']) ? $_GET['design'] : sejolisa_carbon_get_post_meta($product_id, 'checkout_design'); $template_file = apply_filters('sejoli/checkout/design/thankyou', $template_file, $checkout_design, $payment_gateway, $grand_total, false); elseif($this->is_renew_order_page) : $max_renewal_day = absint( $this->current_order['product']->subscription['max_renewal'] ); if(isset($_GET['order_id'])) { $respond = sejolisa_get_order([ 'ID' => $_GET['order_id'] ]); $product_id = $respond['orders']['product_id']; } else { $product_id = $post->ID; } $design = sejolisa_carbon_get_post_meta($product_id, 'checkout_design'); if( 0 < $max_renewal_day ) : $response = sejolisa_get_subscription_by_order( $this->current_order['ID'] ); if( true === $response['valid'] ) : if ($max_renewal_day <= sejolisa_get_difference_day( strtotime( $response['subscription']->end_date) ) ) : return SEJOLISA_DIR . 'template/checkout/renew-closed.php'; endif; endif; endif; $template_file = apply_filters('sejoli/checkout/design/thankyou', $template_file, $design, '', 0, true); endif; return $template_file; } /** * Filter to add design thankyou template * Hooked via filter sejoli/checkout/design/thankyou, priority 10, 3 * @since 1.1.7 * @param array $designs * @return array */ public function sejoli_checkout_thankyou_filter($template_file, $design, $payment_gateway, $grand_total, $is_renew_order_page) { if (true === $is_renew_order_page) : switch ($design) : case 'version-2': $template_file = SEJOLISA_DIR . 'template/checkout/v2/checkout-renew.php'; break; case 'modern': $template_file = SEJOLISA_DIR . 'template/checkout/modern/checkout-renew.php'; break; case 'compact': $template_file = SEJOLISA_DIR . 'template/checkout/compact/checkout-renew.php'; break; case 'less': $template_file = SEJOLISA_DIR . 'template/checkout/less/checkout-renew.php'; break; case 'smart': $template_file = SEJOLISA_DIR . 'template/checkout/smart/checkout-renew.php'; break; default: $template_file = SEJOLISA_DIR . 'template/checkout/checkout-renew.php'; break; endswitch; else: switch ($design) : case 'version-2': $template_file = ($payment_gateway == "cod") ? ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/v2/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/v2/thankyou-cod.php') : ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/v2/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/v2/thankyou.php'); break; case 'modern': $template_file = ($payment_gateway == "cod") ? ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/modern/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/modern/thankyou-cod.php') : ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/modern/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/modern/thankyou.php'); break; case 'compact': $template_file = ($payment_gateway == "cod") ? ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/compact/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/compact/thankyou-cod.php') : ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/compact/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/compact/thankyou.php'); break; case 'less': $template_file = ($payment_gateway == "cod") ? ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/less/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/less/thankyou-cod.php') : ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/less/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/less/thankyou.php'); break; case 'smart': $template_file = ($payment_gateway == "cod") ? ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/smart/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/smart/thankyou-cod.php') : ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/smart/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/smart/thankyou.php'); break; default: $template_file = ($payment_gateway == "cod") ? ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/thankyou-cod.php') : ($grand_total == 0 ? SEJOLISA_DIR . 'template/checkout/thankyou-free.php' : SEJOLISA_DIR . 'template/checkout/thankyou.php'); break; endswitch; endif; return $template_file; } /** * Display renew checkout * Hooked via action parse_request, priority 999 * @since 1.1.9 * @return void */ public function setup_checkout_renew() { if(sejolisa_verify_checkout_page('renew') && isset($_GET['order_id'])) : global $sejolisa, $post; $order_id = intval($_GET['order_id']); if( !is_user_logged_in() ) : ob_start(); sejoli_get_template_part('checkout/renew-login.php'); $login_form = ob_get_contents(); ob_end_clean(); wp_die( sprintf( __('Anda harus login terlebih dahulu untuk melakukan pembaharuan langganan order %s. %s', 'sejoli'), $order_id, $login_form ), __('Login terlebih dahulu', 'sejoli') ); endif; $order_id = intval($_GET['order_id']); $current_user_id = get_current_user_id(); $response = sejolisa_check_subscription($order_id); $subscription = $response['subscription']; if(false === $response['valid'] || $current_user_id !== intval($subscription->user_id) ): wp_die( sprintf( __('Anda tidak bisa mengakses pembaharuan langganan order %s', 'sejoli'), $order_id), __('Tidak bisa melakukan pembaharuan langganan', 'sejoli') ); else : $sejolisa['subscription'] = (array) $subscription; endif; endif; } /** * sejoli checkout loading by ajax * hooked via action parse_request * * @return json */ public function loading_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-loading' ) ) : $request = wp_parse_args($_POST, [ 'order_id' => 0 ]); if ( intval( $request['order_id'] ) > 0 ) : do_action('sejoli/frontend/checkout/loading', $request); $response = sejolisa_get_respond('loading'); else: $response = [ 'valid' => false ]; endif; wp_send_json($response); endif; } /** * sejoli checkout loading * hooked via action sejoli/frontend/checkout/loading * * @return json */ public function loading( $request ) { $response = [ 'valid' => true, 'redirect_link' => site_url('checkout/thank-you?order_id='.$request['order_id']), ]; sejolisa_set_respond($response,'loading'); } /** * sejoli get shipping methods by ajax * hooked via action parse_request * * @return json */ public function get_shipping_methods_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-get-shipping-methods' ) ) : $request = wp_parse_args( $_POST, [ 'product_id' => NULL, 'district_id' => NULL, 'district_name' => NULL, 'quantity' => 1, 'shipment' => NULL, 'variants' => [], ]); $response = []; $response = apply_filters('sejoli/frontend/checkout/shipping-methods', [], $request ); wp_send_json($response); endif; } /** * setup shipping methods data * hooked via filter sejoli/frontend/checkout/shipping-methods * * @return void */ public function shipping_methods( $shipping_methods, $request ) { $shipping_details = [ 'shipping_methods' => [], 'messages' => '' ]; do_action('sejoli/checkout/shipment-calculate', $request); $shipment_data = sejolisa_get_respond('shipment'); if ( $shipment_data['valid'] && !empty( $shipment_data['shipment'] ) ) : foreach ( $shipment_data['shipment'] as $key => $value ) : $shipping_details['shipping_methods'][] = [ 'id' => $key, 'title' => $value, 'image' => '', ]; endforeach; $shipping_details['messages'] = $shipment_data['messages']; endif; return $shipping_details; } /** * sejoli get subdistrict by ajax * hooked via action parse_request * * @return json */ public function get_subdistrict_by_ajax() { if ( sejoli_ajax_verify_nonce( 'sejoli-checkout-ajax-get-subdistrict' ) ) : $request = wp_parse_args( $_POST,[ 'term' => '', ]); $response = sejolisa_get_district_options( $request['term'] ); wp_send_json($response); endif; } /** * Trigger auto-fill coupon if there is coupon data in cookie * Hooked via action wp_footer, priority 999 * @since 1.5.1 * @return void */ public function trigger_coupon_fill() { global $post; if ( is_singular('sejoli-product') ) : $data = sejolisa_get_affiliate_cookie(); if( ( isset($data['coupon']) && isset($data['coupon'][$post->ID]) ) || ( isset( $_GET['coupon'] ) ) ) : $user_coupon = isset( $_GET['coupon'] ) ? $_GET['coupon'] : $data['coupon'][$post->ID]; require_once( plugin_dir_path( __FILE__ ) . 'partials/coupon/autofill.php' ); endif; endif; } } public.php 0000644 00000062535 15172717071 0006556 0 ustar 00 <?php namespace SejoliSA; /** * The public-facing functionality of the plugin. * * @link https://ridwan-arifandi.com * @since 1.0.0 * * @package Sejoli * @subpackage Sejoli/public */ /** * The public-facing functionality of the plugin. * * Defines the plugin name, version, and two examples hooks for how to * enqueue the public-facing stylesheet and JavaScript. * * @package Sejoli * @subpackage Sejoli/public * @author Ridwan Arifandi <orangerdigiart@gmail.com> */ class Front { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * List of CSS that will be enabled in custom page * @var array */ private $css_enabled = [ 'key' => [], 'src' => [] ]; /** * List of JS that will be enabled in custom page * @var array */ private $js_enabled = [ 'key' => [], 'src' => [] ]; /** * List of messages * @var array */ private $messages = [ 'info' => [], 'warning' => [], 'error' => [], 'success' => [] ]; /** * Enable semantic theme * @since 1.1.7 * @var boolean */ protected $enable_semantic = false; /** * Set post type that Sejoli Member Area tempate page cant be used in * @since 1.3.2 * @var array */ protected $exclude_post_types = array(); /** * Initialize the class and set its properties. * * @since 1.0.0 * @since 1.3.2 Initialized exclude post types variable for Sejoli Member Page use * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->exclude_post_types = array( SEJOLI_PRODUCT_CPT ); $this->enable_css_and_js(); } /** * Give permission to selected CSS and JS * @return void */ private function enable_css_and_js() { $this->css_enabled = [ 'src' => [ // 'plugins/woocommerce', 'wp-includes', 'wp-admin' ], 'key' => [ // /'wc-' ] ]; $this->js_enabled = [ 'src' => [ // 'woocommerce', 'wp-includes', 'wp-admin' ], 'key' => [ // 'wc-' ] ]; } /** * Register CSS Files. * Hooked via action hook wp_enqueue_scripts, priority 999 * @since 1.0.0 Initialization * @since 1.1.7 Enable semantic * @since 1.6.2 Add JSTree for affiliasi-network page * @return void */ public function enqueue_styles() { $enable_semantic = apply_filters('sejoli/enable', $this->enable_semantic); if(true === $enable_semantic) : wp_register_style ('semantic-ui', 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css',[],'2.4.1','all'); wp_enqueue_style ($this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/style.css', ['semantic-ui'], $this->version, 'all' ); endif; wp_register_style( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/css/select2.min.css', [], '4.0.10', 'all' ); wp_register_style( 'daterangepicker', 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.0.5/daterangepicker.min.css', [], '3.0.5', 'all' ); wp_register_style( 'datatables-semantic-ui', 'https://cdn.datatables.net/1.10.19/css/dataTables.semanticui.min.css', ['semantic-ui'], '1.10.19', 'all' ); wp_register_style( 'sejoli-member-area', plugin_dir_url( __FILE__ ) . 'css/sejoli-member-area.css', [], $this->version, 'all' ); wp_register_style( 'sejoli-dashboard', plugin_dir_url( __FILE__ ) . 'css/home.css', [], $this->version, 'all' ); wp_register_style( 'jstree', 'https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.10/themes/default/style.min.css', '3.3.10' ); // enqueue jstree style di sini if ( sejolisa_is_member_area_page() ) : wp_enqueue_style( 'daterangepicker' ); wp_enqueue_style( 'datatables-semantic-ui' ); wp_enqueue_style( 'sejoli-member-area' ); wp_enqueue_style( 'select2' ); endif; if( sejolisa_is_member_area_page('home') ) : wp_enqueue_style( 'sejoli-dashboard' ); endif; if( sejolisa_is_member_area_page('affiliasi-network') ) : wp_enqueue_style( 'jstree' ); endif; if(true === $enable_semantic) : wp_enqueue_style( 'sejoli-member-area' ); endif; } /** * Register JS Files. * Hooked via action hook wp_enqueue_scripts, priority 999 * @since 1.0.0 initialization * @since 1.1.7 Enable semantic * @since 1.6.2 Add JSTree for affiliasi-network page * @return void */ public function enqueue_scripts() { $enable_semantic = apply_filters('sejoli/enable', $this->enable_semantic); if(true === $enable_semantic) : wp_register_script ('semantic-ui', 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js',['jquery'],'2.4.1',false); wp_enqueue_script ($this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/sejoli-public.js', ['semantic-ui','jquery'], $this->version, false ); endif; wp_register_script( 'tinymce', 'https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.0.15/tinymce.min.js', ['jquery'], NULL, false ); wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/js/select2.min.js', ['jquery'], NULL, false ); wp_register_script( 'moment-js', 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.0.5/moment.min.js', ['jquery'], NULL, false ); wp_register_script( 'daterangepicker', 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.0.5/daterangepicker.min.js', ['jquery'], NULL, false ); wp_register_script( 'datatables', 'https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js', ['jquery'], NULL, false ); wp_register_script( 'datatables-semantic-ui','https://cdn.datatables.net/1.10.16/js/dataTables.semanticui.min.js', ['jquery'], NULL, false ); wp_register_script( 'chartjs', 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js', [], NULL, false ); wp_register_script( 'jsrender', 'https://cdnjs.cloudflare.com/ajax/libs/jsrender/0.9.90/jsrender.min.js', [], NULL, false ); wp_register_script( 'clipboardjs', 'https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js', [], NULL, false ); wp_register_script( 'blockUI', 'https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js', [], NULL, false ); wp_register_script( 'sejoli-member-area', plugin_dir_url( __FILE__ ) . 'js/sejoli-member-area.js', ['semantic-ui','jquery'], $this->version, false ); wp_register_script( 'jstree', 'https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.10/jstree.min.js', array('jquery'), '3.3.10', true); wp_localize_script( "datatables", "dataTableTranslation", array( "all" => __('Semua','sejoli'), "decimal" => ",", "emptyTable" => __("Tidak ada data yang bisa ditampilkan","sejoli"), "info" => __("Menampikan _START_ ke _END_ dari _TOTAL_ data","sejoli"), "infoEmpty" => __("Menampikan 0 ke 0 dari 0 data","sejoli"), "infoFiltered" => __("Menyaring dari total _MAX_ data","sejoli"), "infoPostFix" => "", "thousands" => ".", "lengthMenu" => __("Menampilkan _MENU_ data","sejoli"), "loadingRecords" => __("Mengambil data...","sejoli"), "processing" => __("Memproses data...","sejoli"), "search" => __("Cari data :","sejoli"), "zeroRecords" => __("Tidak ditemukan data yang sesuai","sejoli"), "paginate" => array( "first" => __("Pertama","sejoli"), "last" => __("Terakhir","sejoli"), "next" => __("Selanjutnya","sejoli"), "previous" => __("Sebelumnya","sejoli") ), "aria" => array( "sortAscending" => __("Klik untuk mengurutkan kolom naik","sejoli"), "sortDescending" => __("Klik untuk mengurutkan kolom turun","sejoli") ) )); wp_localize_script( 'sejoli-member-area', 'sejoli_member_area', array( 'ajax_nonce' => wp_create_nonce('ajax-nonce'), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'ajax_url' => site_url('/'), 'get_commission' => site_url( 'sejoli-ajax/get-commission/' ), 'get_commission_detail' => site_url( 'sejoli-ajax/get-commission-detail/' ), 'get_affiliate_link' => site_url( 'sejoli-ajax/get-affiliate-link/' ), 'get_affiliate_help' => site_url( 'sejoli-ajax/get-affiliate-help/' ), 'get_affiliate_help_detail' => site_url( 'sejoli-ajax/get-affiliate-help-detail/' ), 'get_affiliate_coupon_user' => site_url( 'sejoli-ajax/get-affiliate-coupon-user/' ), 'get_coupon_parent_list_select2' => site_url( 'sejoli-ajax/get-affiliate-coupon-parent-list/' ), 'get_affiliate_order' => site_url( 'sejoli-ajax/get-affiliate-order/' ), 'add_affiliate_coupon_user' => site_url( 'sejoli-ajax/add-affiliate-coupon-user/' ), 'get_order_detail' => site_url( 'sejoli-ajax/get-order-detail/' ), 'get_leaderboard' => site_url( 'sejoli-ajax/get-leaderboard/' ), 'get_subdistrict' => wp_create_nonce('sejoli-checkout-ajax-get-subdistrict'), 'update_profile' => site_url( 'sejoli-ajax/update-profile/' ), 'text' => [ 'main' => __('Pengaturan', 'sejoli'), 'currency' => sejolisa_currency_format(), 'status' => [ 'pending' => __('Belum Aktif', 'sejoli'), 'inactive' => __('Tidak Aktif', 'sejoli'), 'active' => __('Aktif', 'sejoli'), 'expired' => __('Berakhir', 'sejoli') ] ], 'commission' => [ 'status' => [ 'pending' => __('Order belum selesai', 'sejoli'), 'added' => __('Belum dibayar', 'sejoli'), 'cancelled' => __('Dibatalkan', 'sejoli'), 'paid' => __('Sudah dibayar', 'sejoli') ], 'table' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-commission-table' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-render-commission-table') ], ], 'color' => sejolisa_get_all_colors(), 'affiliate' => [ 'order' => [ 'nonce' => wp_create_nonce('sejoli-list-orders') ], 'export_prepare' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-order-export-prepare' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-order-export-prepare') ], 'link' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-product-affiliate-link-list' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-list-product-affiliate-link') ], 'help' => [ 'nonce' => wp_create_nonce('sejoli-list-product-affiliate-help'), ], 'bonus_editor' => [ 'get' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-get-bonus-content' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-affiliate-bonus-content'), ], 'update' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-update-bonus-content' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-affiliate-bonus-content'), ] ], 'network' => [ 'list' =>[ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-get-network-list', 'nonce' => wp_create_nonce('sejoli-affiliate-get-network-list') ], admin_url('admin-ajax.php')), ], 'detail' =>[ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-get-network-detail', 'nonce' => wp_create_nonce('sejoli-affiliate-get-network-detail') ], admin_url('admin-ajax.php')), ], ], 'facebook_pixel' => [ 'get' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-get-facebook-pixel' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-affiliate-get-facebook-pixel'), ], 'update' => [ 'nonce' => wp_create_nonce('sejoli-affiliate-update-facebook-pixel'), ] ], 'facebook_conversion' => [ 'get' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-get-facebook-conversion' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-affiliate-get-facebook-conversion'), ], 'update' => [ 'nonce' => wp_create_nonce('sejoli-affiliate-update-facebook-conversion'), ] ], 'tiktok_conversion' => [ 'get' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-affiliate-get-tiktok-conversion' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-affiliate-get-tiktok-conversion'), ], 'update' => [ 'nonce' => wp_create_nonce('sejoli-affiliate-update-tiktok-conversion'), ] ] ], 'order' => [ 'table' => [ 'nonce' => wp_create_nonce('sejoli-list-orders') ], 'detail' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-order-detail' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-order-detail') ], 'status' => apply_filters('sejoli/order/status', []) ], 'subscription' => [ 'table' => [ 'nonce' => wp_create_nonce('sejoli-list-subscriptions') ], 'detail' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-order-detail' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-order-detail') ], 'status' => apply_filters('sejoli/order/status', []) ], 'subscription' => [ 'type' => [ 'subscription-tryout' => 'tryout', 'subscription-signup' => 'signup', 'subscription-regular' => 'regular', ] ], 'coupon' => [ 'table' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-coupon-table' ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-render-coupon-table') ], 'list' => [ 'nonce' => wp_create_nonce('sejoli-list-parent-coupons'), ], 'add' => [ 'nonce' => wp_create_nonce('sejoli-create-affiliate-coupon'), ] ], 'product' => [ 'table' => [ 'nonce' => wp_create_nonce('sejoli-product-table') ], 'select' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-product-options', ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-render-product-options') ], 'placeholder' => __('Pencarian produk', 'sejoli') ], 'leaderboard' => [ 'nonce' => wp_create_nonce('sejoli-statistic-get-commission-data') ], 'akses' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-access-list-by-product', ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-access-list-by-product'), ], 'bonus' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-access-get-bonus', ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-access-bonus') ], 'district_select' => __('Silakan Ketik Nama Kecamatannya', 'sejoli'), 'coupon_select' => __('--Pilih Kupon Utama--', 'sejoli') ) ); if ( sejolisa_is_member_area_page() ) : wp_enqueue_script( 'tinymce' ); wp_enqueue_script( 'moment-js' ); wp_enqueue_script( 'daterangepicker' ); wp_enqueue_script( 'datatables' ); wp_enqueue_script( 'datatables-semantic-ui' ); wp_enqueue_script( 'chartjs' ); wp_enqueue_script( 'jsrender' ); wp_enqueue_script( 'clipboardjs' ); wp_enqueue_script( 'blockUI' ); wp_enqueue_script( 'select2' ); wp_enqueue_script( 'jstree' ); wp_enqueue_script( 'sejoli-member-area' ); endif; if( sejolisa_is_member_area_page('affiliasi-network') ) : wp_enqueue_script( 'jstree' ); endif; if($enable_semantic) : wp_enqueue_script( 'sejoli-member-area' ); wp_enqueue_script( $this->plugin_name ); endif; } /** * Set messages * Hooked via filter sejoli/set-messages, priority 999 * @param array $messages * @param string $info * @return array $messages */ public function set_messages($messages,$type = 'info') { global $sejoli; $this->messages[$type] += $messages; $sejoli['messages'] = $this->messages; } /** * Add query vars for handle __sejoli_ajax_action. * Hooked via filter query_vars, priority 100 * @return void */ public function add_query_vars($vars){ $vars[] = '__sejoli_ajax_action'; return $vars; } /** * Add endpoint. * Hooked via action init, priority 100 * @return void */ public function add_endpoint() { add_rewrite_rule('^sejoli-ajax/([^/]+)/?$','index.php?__sejoli_ajax_action=$matches[1]','top'); } /** * Add ajax action * Hooked via action parse_request, priority 100 * * @return void */ public function add_ajax_action() { global $wp; if ( ! isset( $wp->query_vars['__sejoli_ajax_action'] ) ) return; do_action( 'sejoli_ajax_' . $wp->query_vars['__sejoli_ajax_action'] ); exit; } /** * Force user when access homepage to member area * Hooked via action template_redirect, priority 100 * @since 1.1.1 * @since 1.4.3 Set with no parameter in sejolisa_verify_checkout_page * @return void */ public function redirect_to_member_area() { global $wp_query; $force_redirect = boolval(sejolisa_carbon_get_theme_option('sejoli_homepage_member_redirect')); if( $force_redirect && ( is_home() || is_front_page() ) && ! isset($wp_query->query['member']) && ! sejolisa_verify_checkout_page ( array( 'loading', 'renew', 'thank-you') ) ) : wp_redirect(home_url('/member-area/')); exit; endif; } /** * Change redirect member-area into alihkan user setelah login url * Hooked via action template_redirect, priority 100 * @since 1.12.1 * @return void */ public function redirect_member_area_alihkan_url_setelah_login() { $keep_dashboard_statistic = boolval(sejolisa_carbon_get_theme_option('sejoli_keep_dashboard_statistic')); $redirected_url = esc_url(sejolisa_carbon_get_theme_option('sejoli_after_login_redirect')); $redirected_url = (!empty($redirected_url)) ? $redirected_url : ''; if( false === $keep_dashboard_statistic && !empty($redirected_url) ) : if( is_user_logged_in() ) : global $wp_query; $get_member = isset($wp_query->query['member']) ? $wp_query->query['member'] : ''; $get_view = isset($wp_query->query['view']) ? $wp_query->query['view'] : ''; if( $get_member === '1' && $get_view === "home" ): if( !empty($redirected_url) ): wp_redirect($redirected_url); exit; endif; endif; endif; endif; } /** * Check if current page is using sejoli-member-page.php * Hooked via action template_redirect, priority 200 * @since 1.1.7 * @since 1.3.2 Add conditional to check if current post type is able to use Sejoli Member Page template * @since 1.3.3 Add more conditional by check if current page is a login or a checkout page * @since 1.4.3 Add conditiona by check if current page is a register page, add check if $post is_a WP_Post * @return void */ public function check_using_member_page() { global $post; if(is_a($post, 'WP_Post') && property_exists($post, 'ID')) : $page_template = get_post_meta($post->ID, '_wp_page_template', true); // Return default template if we don't have a custom one defined if( !sejoli_is_a_member_page('login') && !sejoli_is_a_member_page('register') && !sejolisa_verify_checkout_page ( array( 'loading', 'renew', 'thank-you') ) && 'sejoli-member-page.php' === $page_template && !in_array($post->post_type, $this->exclude_post_types)) : if( !is_user_logged_in() ) : wp_die( sprintf( __('Anda harus login terlebih dahulu untuk mengakses halaman ini.<br /> Silahkan login melalui link <a href="%s">ini</a>', 'login'), site_url('member-area/login') ), __('Anda tidak diperbolehkan mengakses halaman ini', 'sejoli') ); exit; endif; $this->enable_semantic = true; endif; endif; } /** * Check if current page is using sejoli-member-page.php * Hooked via filter template_include, priority 10 * @since 1.1.7 * @since 1.3.0 Change priority from 1 to 10 * @param string $template Template file * @return string */ public function view_member_template($template) { global $post; // Return template if post is empty if ( ! $post ) : return $template; endif; // Return default template if we don't have a custom one defined if(false !== $this->enable_semantic) : $template = SEJOLISA_DIR . 'template/member-template.php'; return $template; endif; return $template; } /** * Enable semantic * Hooked via filter sejoli/enable, priority 100 * @since 1.1.7 * @return boolean */ public function enable_semantic($enable_semantic) { return (true === $enable_semantic) ? true : $this->enable_semantic; } /** * Set body clasess for Sejoli Member Area template * Hooked via filter body_class, priority 999 * @since 1.5.4.1 * @param array $classes * @return array */ public function set_body_classes( array $classes ) { if(is_page_template('sejoli-member-page.php')) : $classes[] = 'sejoli'; endif; return $classes; } /** * Add inline CSS script * Hooked via action wp_head, priority 100 * @since 1.2.0 * @since 1.5.4.1 * @return boolean */ public function add_inline_style() { ?> <style media="screen"> /* #wpadminbar { background-color: #179822 !important; } */ </style> <?php if( ( !sejoli_is_a_member_page() && !is_page_template('sejoli-member-page.php') ) || true !== boolval(sejolisa_carbon_get_theme_option('activate_custom_member_area_style')) ) : return; endif; ?> <style media="screen"> body.sejoli { background-color: <?php echo sejolisa_carbon_get_theme_option('member_area_bg_color'); ?>!important; } body.sejoli .sejolisa-memberarea-menu.ui.inverted.menu { background-color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_bg_color'); ?>!important; } body.sejoli .ui.inverted.menu .item, body.sejoli .ui.inverted.menu .item>a:not(.ui) { color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_link_color'); ?>!important; background-color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_menu_bg_color'); ?>!important; } body.sejoli .ui.inverted.menu .item:not(.header-menu):hover { color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_link_hover_color'); ?>!important; background-color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_menu_hover_bg_color'); ?>!important; } body.sejoli .ui.inverted.menu .active.item { color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_link_active_color'); ?>!important; background-color: <?php echo sejolisa_carbon_get_theme_option('member_area_sidebar_menu_active_bg_color'); ?>!important; } body.sejoli .master-menu { border-bottom-width: 0; } body.sejoli .four.cards .ui.card.orange .content { background-color: <?php echo sejolisa_carbon_get_theme_option('statistic_lead'); ?>!important; color: <?php echo sejolisa_carbon_get_theme_option('statistic_lead_color'); ?>!important; } body.sejoli .four.cards .ui.card.orange .content .header { color: <?php echo sejolisa_carbon_get_theme_option('statistic_lead_color'); ?>!important; } body.sejoli .four.cards .ui.card.green .content { background-color: <?php echo sejolisa_carbon_get_theme_option('statistic_sale'); ?>!important; color: <?php echo sejolisa_carbon_get_theme_option('statistic_sale_color'); ?>!important; } body.sejoli .four.cards .ui.card.green .content .header { color: <?php echo sejolisa_carbon_get_theme_option('statistic_sale_color'); ?>!important; } body.sejoli .four.cards .ui.card.blue .content { background-color: <?php echo sejolisa_carbon_get_theme_option('statistic_omset'); ?>!important; color: <?php echo sejolisa_carbon_get_theme_option('statistic_omset_color'); ?>!important; } body.sejoli .four.cards .ui.card.blue .content .header { color: <?php echo sejolisa_carbon_get_theme_option('statistic_omset_color'); ?>!important; } body.sejoli .four.cards .ui.card.light-green .content { background-color: <?php echo sejolisa_carbon_get_theme_option('statistic_komisi'); ?>!important; color: <?php echo sejolisa_carbon_get_theme_option('statistic_komisi_color'); ?>!important; } body.sejoli .ui.cards.information.daily .content.value { background-color:white!important; color: black!important; } body.sejoli .four.cards .ui.card.light-green .content .header { color: <?php echo sejolisa_carbon_get_theme_option('statistic_komisi_color'); ?>!important; } <?php echo sejolisa_carbon_get_theme_option('member_area_css'); ?> </style> <?php } } leaderboard.php 0000644 00000003010 15172717071 0007523 0 ustar 00 <?php namespace SejoliSA\Front; class Leaderboard { /** * ajax get leaderboard * hooked via action sejoli_ajax_get-leaderboard, priotrity 100 * * @return void */ public function ajax_get_leaderboard() { check_ajax_referer('ajax-nonce', 'security'); $filter = array(); foreach ( $_POST['filter'] as $key => $value ) : if ( $value['val'] ) : $filter[$value['name']] = $value['val']; endif; endforeach; // $respond = \sejoli\Leaderboard::set_filter( $filter ) // ->get_list() // ->respond(); $data = array(); // if ( $respond['valid'] && is_object( $respond['leaderboard'] ) ) : // foreach ( $respond['leaderboard'] as $key => $value ) : // $user = get_userdata( $value->user_id ); // $data[] = array( // 'id' => $key+1, // 'name' => $user->display_name, // 'avatar'=> get_avatar_url( $value->user_id ), // 'sales' => $value->sales, // ); $data[] = array( 'id' => 1, 'name' => 'Jhon Doe', 'avatar'=> get_avatar_url(), 'sales' => 23, ); // endforeach; // endif; wp_send_json($data); } } affiliasi-kupon.php 0000644 00000013033 15172717071 0010346 0 ustar 00 <?php namespace SejoliSA\Front; class Affiliasi_Kupon { /** * ajax get affilaite coupon user * hooked via action sejoli_ajax_get-affiliate-coupon-user, priotrity 999 * * @return void */ public function ajax_get_affiliate_coupon_user() { $_post = json_decode( file_get_contents('php://input'), true ); if ( ! wp_verify_nonce( $_post['security'], 'ajax-nonce' ) ) : die( 'invalid nonce' ); endif; $request = wp_parse_args($_post,[ 'start' => 0, 'length' => 10, 'draw' => 1, ]); $search = []; $order = [[ 'column'=> 'ID', 'sort' => 'desc' ]]; if ( isset( $request['search'] ) && 0 < count( $request['search'] ) ) : foreach( $request['search'] as $_search ) : $search[$_search['name']] = [ 'name' => $_search['name'], 'val' => $_search['val'] ]; endforeach; endif; if( isset( $request['order'] ) && 0 < count( $request['order'] ) ) : $i = 0; foreach( $request['order'] as $_order ) : $order[$i]['sort'] = $_order['dir']; switch( $_order['column'] ) : case 0 : $order[$i]['column'] = 'created_at'; break; endswitch; $i++; endforeach; endif; $filter = [ 'start' => $request['start'], 'length' => $request['length'], 'search' => $search, 'order' => $order, ]; $affiliate_id = get_current_user_id(); // $respond = \sejoli\Coupon::set_affiliate_id( $affiliate_id ) // ->set_filter( $filter ) // ->get_list_by_user() // ->respond(); $coupons = []; $recordsTotal = 0; // if ( $respond['valid'] && is_object( $respond['coupons'] ) ) : // foreach ( $respond['coupons'] as $key => $value ): // $coupon_parent = ''; // $coupon = new \WC_Coupon( $value->coupon_parent_id ); // if ( 0 !== $coupon->get_id() ) { // $coupon_parent = $coupon->get_code(); // } // if ( 1 === intval($value->active) ) : // $active = '<a class="ui green label">aktif</a>'; // else: $active = '<a class="ui red label">tidak aktif</a>'; // endif; // $coupons[] = array( // date('d-m-Y', strtotime($value->created_at)), // $coupon_parent, // $value->coupon_code, // $value->usage, // $active, // ); $coupons[] = array( date('d-m-Y', strtotime($value->created_at)), '123', 'tes123', 10, $active, ); // endforeach; // $recordsTotal = $respond['recordsTotal']; // endif; $response = array( 'data' => $coupons, 'draw' => $request['draw'], 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsTotal, ); wp_send_json($response); } /** * get coupon parent list * hooked via action, sejoli_ajax_get-affiliate-coupon-parent-list, priority 100 * * @return void */ public function ajax_get_coupon_parent_list_select2() { check_ajax_referer( 'ajax-nonce', 'security' ); $search = sanitize_text_field( $_POST['search'] ); // $respond = \sejoli\Coupon::get_parent_list( $search ) // ->respond(); $coupon_parent = []; $recordsTotal = 0; // if ( $respond['valid'] && is_array( $respond['coupon_parent'] ) ) : // foreach ( $respond['coupon_parent'] as $key => $value ): // $coupon_parent[] = array( // 'id' => $value['ID'], // 'text' => $value['code'], // ); $coupon_parent[] = array( 'id' => 1, 'text' => '123', ); // endforeach; // endif; wp_send_json($coupon_parent); } /** * ajax add affilaite coupon user * hooked via action sejoli_ajax_add-affiliate-coupon-user, priotrity 100 * * @return void */ public function ajax_add_affiliate_coupon_user() { if ( ! wp_verify_nonce( $_POST['security'], 'ajax-nonce' ) ) : die( 'invalid nonce' ); endif; $args = array( 'user_id' => get_current_user_id() ); // if ( isset( $_POST['data'] ) && is_array( $_POST['data'] ) ) : // foreach ( $_POST['data'] as $key => $value ) : // $name = $value['name']; // $args[$name] = $value['val']; // endforeach; // endif; // $add_coupon = sejoli_add_coupon_affiliate($args); // if ( $add_coupon['valid'] ) : // $coupon = $add_coupon['coupon']; // if ( isset( $coupon['ID'] ) && !empty( $coupon['ID'] ) ) : wp_send_json_success( [ __( 'Kupon berhasil ditambahkan', 'sejoli' ) ] ); // else: // wp_send_json_error( [ __( 'Kupon gagal ditambahkan', 'sejoli' ) ] ); // endif; // else: // wp_send_json_error( $add_coupon['messages'] ); // endif; } } facebook-tiktok-conversion.php 0000644 00000042657 15172717071 0012542 0 ustar 00 <?php namespace SejoliSA\Front; use Carbon_Fields\Container; use Carbon_Fields\Field; class Facebook_Tiktok_Conversion { /** * The ID of this plugin. * * @since 1.3.2 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.3.2 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.3.2 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Set facebook pixel in local data * Hooked via action wp_enqueue_scripts, priority 888 * @since 1.3.2 * @since 1.5.1.1 Remove content_type and content_category * @return void */ public function set_localize_js_vars() { if( sejolisa_is_member_area_page('akses') ) : wp_localize_script( 'sejoli-member-area', 'sejoli_fb_tiktok_conversion', [ 'fb_tiktok_access_pixel_conversion' => [ 'ajaxurl' => add_query_arg([ 'action' => 'sejoli-fb-tiktok-access-pixel-conversion', ], admin_url('admin-ajax.php')), 'nonce' => wp_create_nonce('sejoli-fb-tiktok-access-pixel-conversion') ], ]); endif; } /** * Track user click access pixel conversion * Hooked via wp_ajax_sejoli-fb-tiktok-access-pixel-conversion, priority 1 * @since 1.0,0 * @return json */ public function fb_tiktok_click_access_pixel_conversion() { $post_data = wp_parse_args($_GET,[ 'nonce' => NULL, 'product' => NULL, 'access_link' => NULL, 'access' => NULL, ]); if( wp_verify_nonce($post_data['nonce'], 'sejoli-fb-tiktok-access-pixel-conversion') && !empty($post_data['product']) && !empty($post_data['access_link']) && !empty($post_data['access']) ) : $user_id = get_current_user_id(); $meta_value = "access-".$post_data['access']; $fb_access_get_value = get_user_meta( $user_id, 'fb_user_click_access_tracks', true ); $fb_conversion_active = boolval(sejolisa_carbon_get_post_meta($post_data['product'], 'fb_conversion_active')); $fb_eventString = esc_attr(sejolisa_carbon_get_post_meta($post_data['product'], 'fb_conversion_event_click_link_access_page')); $tiktok_access_get_value = get_user_meta( $user_id, 'tiktok_user_click_access_tracks', true ); $tiktok_conversion_active = boolval(sejolisa_carbon_get_post_meta($post_data['product'], 'tiktok_conversion_active')); $tiktok_eventString = esc_attr(sejolisa_carbon_get_post_meta($post_data['product'], 'tiktok_conversion_event_click_link_access_page')); if( !empty( $fb_access_get_value ) ) : if ( ! array($fb_access_get_value) ) : $fb_access_get_value = array(); endif; if( !in_array( $meta_value, $fb_access_get_value ) ) : $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_click_access_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $post_data['product'], $fb_eventString ); endif; endif; else: $fb_access_get_value = array(); $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_click_access_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $post_data['product'], $fb_eventString ); endif; endif; if( !empty( $tiktok_access_get_value ) ) : if ( ! array($tiktok_access_get_value) ) : $tiktok_access_get_value = array(); endif; if( !in_array( $meta_value, $tiktok_access_get_value ) ) : $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_click_access_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $post_data['product'], $tiktok_eventString ); endif; endif; else: $tiktok_access_get_value = array(); $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_click_access_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $post_data['product'], $tiktok_eventString ); endif; endif; endif; return; } /** * Fungsi untuk mencari string yang mengandung angka tertentu * @since 1.0,0 * @return json */ public function containsNumber($string, $number) { return mb_strpos($string, $number) !== false; } /** * Track user views some pages pixel conversion * @since 1.0,0 * @return json */ public function fb_tiktok_view_some_pages_pixel_conversion() { global $wp; if( is_user_logged_in() ) : if( isset( $wp->query_vars['sejolisa_checkout_page'], $_GET['order_id'] ) && $wp->query_vars['sejolisa_checkout_page'] === 'thank-you' ) : $respond = sejolisa_get_order([ 'ID' => $_GET['order_id'] ]); if(false !== $respond['valid'] && isset($respond['orders']) && isset($respond['orders']['ID'])) : $order = $respond['orders']; $post_data = [ 'ID' => $order['ID'], 'page' => 'invoice' ]; $order_id = $post_data['ID']; $fb_conversion_active = boolval(sejolisa_carbon_get_post_meta($order['product_id'], 'fb_conversion_active')); $fb_eventString = esc_attr(sejolisa_carbon_get_post_meta($order['product_id'], 'fb_conversion_event_on_invoice_page')); $tiktok_conversion_active = boolval(sejolisa_carbon_get_post_meta($order['product_id'], 'tiktok_conversion_active')); $tiktok_eventString = esc_attr(sejolisa_carbon_get_post_meta($order['product_id'], 'tiktok_conversion_event_on_invoice_page')); $user_id = get_current_user_id(); $meta_value = "views-".$post_data['page'].'-'.$post_data['ID']; $fb_access_get_value = get_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', true ); $tiktok_access_get_value = get_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', true ); if(is_array($fb_access_get_value)) : $filterDuplicateDataFb = array_filter($fb_access_get_value, function($item) use ($order_id) { return $this->containsNumber($item, $order_id); }); else : $filterDuplicateDataFb = null; endif; // Periksa apakah ada string yang mengandung angka tertentu dalam array if (empty($filterDuplicateDataFb)) : if( !empty( $fb_access_get_value ) ) : if ( ! array($fb_access_get_value) ) : $fb_access_get_value = array(); endif; $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $order, $fb_eventString ); endif; else: $fb_access_get_value = array(); $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $order, $fb_eventString ); endif; endif; endif; if(is_array($tiktok_access_get_value)) : $filterDuplicateDataTikTok = array_filter($tiktok_access_get_value, function($item) use ($order_id) { return $this->containsNumber($item, $order_id); }); else : $filterDuplicateDataTiktok = null; endif; if (empty($filterDuplicateDataTikTok)) : if( !empty( $tiktok_access_get_value ) ) : if ( ! array($tiktok_access_get_value) ) : $tiktok_access_get_value = array(); endif; $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $order, $tiktok_eventString ); endif; else: $tiktok_access_get_value = array(); $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $order, $tiktok_eventString ); endif; endif; endif; return true; endif; elseif( is_singular( 'sejoli-product' ) ) : $post_data = [ 'ID' => get_the_ID(), 'page' => 'checkout' ]; $fb_conversion_active = boolval(sejolisa_carbon_get_post_meta($post_data['ID'], 'fb_conversion_active')); $fb_eventString = esc_attr(sejolisa_carbon_get_post_meta($post_data['ID'], 'fb_conversion_event_on_checkout_page')); $tiktok_conversion_active = boolval(sejolisa_carbon_get_post_meta($post_data['ID'], 'tiktok_conversion_active')); $tiktok_eventString = esc_attr(sejolisa_carbon_get_post_meta($post_data['ID'], 'tiktok_conversion_event_on_checkout_page')); $user_id = get_current_user_id(); $meta_value = "views-".$post_data['page'].'-'.$post_data['ID'].date('YmdHi'); $fb_access_get_value = get_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', true ); $tiktok_access_get_value = get_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', true ); $order_id = $post_data['ID'].date('YmdHi'); if(is_array($fb_access_get_value)) : $filterDuplicateDataFb = array_filter($fb_access_get_value, function($item) use ($order_id) { return $this->containsNumber($item, $order_id); }); else : $filterDuplicateDataFb = null; endif; // Periksa apakah ada string yang mengandung angka tertentu dalam array if (empty($filterDuplicateDataFb)) : if( !empty( $fb_access_get_value ) ) : if ( ! array($fb_access_get_value) ) : $fb_access_get_value = array(); endif; $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $post_data['ID'], $fb_eventString ); endif; else: $fb_access_get_value = array(); $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $post_data['ID'], $fb_eventString ); endif; endif; endif; if(is_array($tiktok_access_get_value)) : $filterDuplicateDataTikTok = array_filter($tiktok_access_get_value, function($item) use ($order_id) { return $this->containsNumber($item, $order_id); }); else : $filterDuplicateDataTiktok = null; endif; if (empty($filterDuplicateDataTikTok)) : if( !empty( $tiktok_access_get_value ) ) : if ( ! array($tiktok_access_get_value) ) : $tiktok_access_get_value = array(); endif; $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $post_data['ID'], $tiktok_eventString ); endif; else: $tiktok_access_get_value = array(); $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $post_data['ID'], $tiktok_eventString ); endif; endif; endif; return true; elseif( sejolisa_verify_checkout_page('renew') ) : if(isset($_GET['order_id'])) { $respond = sejolisa_get_order([ 'ID' => $_GET['order_id'] ]); $product_id = $respond['orders']['product_id']; } else { $product_id = $post->ID; } $post_data = [ 'ID' => $product_id, 'page' => 'checkout_renew' ]; $fb_conversion_active = boolval(sejolisa_carbon_get_post_meta($post_data['ID'], 'fb_conversion_active')); $fb_eventString = esc_attr(sejolisa_carbon_get_post_meta($post_data['ID'], 'fb_conversion_event_on_checkout_page')); $tiktok_conversion_active = boolval(sejolisa_carbon_get_post_meta($post_data['ID'], 'tiktok_conversion_active')); $tiktok_eventString = esc_attr(sejolisa_carbon_get_post_meta($post_data['ID'], 'tiktok_conversion_event_on_checkout_page')); $user_id = get_current_user_id(); $meta_value = "views-".$post_data['page'].'-'.$post_data['ID'].date('YmdHi'); $fb_access_get_value = get_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', true ); $tiktok_access_get_value = get_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', true ); $order_id = $post_data['ID'].date('YmdHi'); if(is_array($fb_access_get_value)) : $filterDuplicateDataFb = array_filter($fb_access_get_value, function($item) use ($order_id) { return $this->containsNumber($item, $order_id); }); else : $filterDuplicateDataFb = null; endif; // Periksa apakah ada string yang mengandung angka tertentu dalam array if (empty($filterDuplicateDataFb)) : if( !empty( $fb_access_get_value ) ) : if ( ! array($fb_access_get_value) ) : $fb_access_get_value = array(); endif; $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $post_data['ID'], $fb_eventString ); endif; else: $fb_access_get_value = array(); $fb_access_get_value[] = $meta_value; if( true === $fb_conversion_active && !empty( $fb_eventString ) ) : update_user_meta( $user_id, 'fb_user_view_'.$post_data['page'].'_page_tracks', $fb_access_get_value ); sejoli_facebook_tracker( $post_data['ID'], $fb_eventString ); endif; endif; endif; if(is_array($tiktok_access_get_value)) : $filterDuplicateDataTikTok = array_filter($tiktok_access_get_value, function($item) use ($order_id) { return $this->containsNumber($item, $order_id); }); else : $filterDuplicateDataTiktok = null; endif; if (empty($filterDuplicateDataTikTok)) : if( !empty( $tiktok_access_get_value ) ) : if ( ! array($tiktok_access_get_value) ) : $tiktok_access_get_value = array(); endif; $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $post_data['ID'], $tiktok_eventString ); endif; else: $tiktok_access_get_value = array(); $tiktok_access_get_value[] = $meta_value; if( true === $tiktok_conversion_active && !empty( $tiktok_eventString ) ) : update_user_meta( $user_id, 'tiktok_user_view_'.$post_data['page'].'_page_tracks', $tiktok_access_get_value ); sejoli_tiktok_tracker( $post_data['ID'], $tiktok_eventString ); endif; endif; endif; return true; endif; else: return false; endif; } } login.php 0000644 00000015204 15172717071 0006377 0 ustar 00 <?php namespace SejoliSA\Front; class Login { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Construction */ public function __construct( $plugin_name, $version) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Replace default register url with sejoli register url * @since 1.1.5 * @param string $register_url Default registration url * @return string Modified registration url */ public function register_url($register_url) { return sejoli_get_endpoint_url('register'); } /** * Replace default login url with sejoli login url * @since 1.1.5 * @param string $login_url Default login url * @return string Modified login url */ public function login_url($login_url) { return sejoli_get_endpoint_url('login'); } /** * Add custom CSS and JS to default WordPress login form * Hooked via action login_enqueue_scripts, priority 100 * @since 1.1.5 * @return void */ public function modify_login_form() { $image_id = sejolisa_carbon_get_theme_option('sejoli_setting_logo'); if(!empty($image_id) && function_exists('wp_get_attachment_image_src')) : $image = wp_get_attachment_image_src($image_id, 'full'); if(false !== $image) : list($image_url, $width, $height) = $image; ?><style type="text/css"> #login h1 a, .login h1 a { background-image: url(<?php echo $image_url ?>); height:<?php echo $height; ?>; width:<?php echo $width; ?>; background-size: <?php echo $width; ?> <?php echo $height; ?>; background-repeat: no-repeat; } </style> <?php endif; endif; wp_enqueue_style( 'sejoli-wp-login', SEJOLISA_URL . 'public/css/wp-login.css', [], $this->version ); wp_enqueue_script( 'jquery' ); } /** * Modify login header url * @since 1.1.5 * @param string $url * @return string */ public function login_header_url($url) { return sejoli_get_endpoint_url(); } /** * Modify login header title * @since 1.1.5 * @param string $title * @return string */ public function login_header_title($title) { return $title; } /** * Add custom JS script for login * Hooked via action login_footer, priority 1 * @since 1.1.5 * @return void */ public function add_js_script() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ console.log('test'); jQuery("input[name='redirect_to']").val('<?php echo add_query_arg(array('action' => 'rp'), sejoli_get_endpoint_url('login')); ?>'); }); </script> <?php } /** * Check if current user is logged in, if user not logged in will be redirect to login page * Hooked via action template_redirect, priority 999 * @since 1.0.0 * @since 1.5.0 Change way to check if current user can access wp-admin * @return void */ public function check_user_login() { if(true === sejoli_is_a_member_page('login') && is_user_logged_in()) : $redirected_url = sejolisa_get_default_member_area_url(); if(current_user_can('manage_sejoli_orders')) : $redirected_url = admin_url(); endif; wp_redirect($redirected_url); exit; // If current page is login and user is not logged in elseif( true === sejoli_is_a_member_page('login') || true === sejoli_is_a_member_page('register') && !is_user_logged_in() ) : return; // If current page is member area but user is not logged in elseif( true === sejoli_is_a_member_page() && !is_user_logged_in() ) : wp_redirect(sejoli_get_endpoint_url('login')); exit; endif; } /** * Check login * Hooked via action sejoli/login * @return void */ public function check_login() { $messages = array(); if(isset($_POST['sejoli-nonce']) && wp_verify_nonce($_POST['sejoli-nonce'],'user-login')) : $email = $_POST['email']; $login = NULL; // If user using username for logged in if(username_exists($email)) : $user = get_user_by('login', $email); $login = $user->user_login; endif; // If user using user email for logged in if(is_email($email) && email_exists($email)) : $user = get_user_by('email', $email); $login = $user->user_login; endif; $data = [ 'user_login' => $login, 'user_password' => $_POST['password'] ]; $user = wp_signon($data); if(is_wp_error($user)) : $messages[] = __('Something wrong with your login.','sejoli'); $messages = array_merge( $messages, $user->get_error_messages()); do_action('sejoli/set-messages', $messages, 'error'); else : $redirected_url = sejolisa_get_default_member_area_url(); if( sejolisa_user_can_access_wp_admin() ) : $redirected_url = admin_url(); endif; wp_redirect($redirected_url); exit; endif; endif; } /** * Display info for reset password request * Hooked via action sejoli/login/rp, priority 999 * @since 1.1.5 * @return void */ public function info_reset_password() { $messages = array(); $messages[] = __('Silahkan cek email anda untuk informasi terkait pergantian password', 'sejoli'); do_action('sejoli/set-messages', $messages, 'info'); } } img/BRISYARIAH.png 0000644 00000150130 15172717071 0007473 0 ustar 00 �PNG IHDR � $ ��8 sRGB ��� gAMA ���a pHYs � ��o�d ��IDATx^�}�eU}�)�������,]�JQD�����o��&�)�b�Fc7��bA� �˲��2;��m��{��]� � ���ϝ7��w�����*�s�F�5j�5P�5jԨQc�@�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F��5�רQ��ޅ��kԨQc�B�5jԨ�w��5j�ػP�~�5j�]�y�F�5�.Լ_�F�{jޯQ�F���9'�z�]�R��eEP]U��7��Q��R�:Q�Ya����F�5��[A~��S�(���$�.���/�ըQ�ƃ �}X�3$��*x{�[����W�X1T�0��kԨ��2��^(��ng3�^�RHvx �����2g��F�5��� ��=�w��;;6`����3*D��cok�Q��C;y���ϯ0�w��g�2��{ vg����O���I�5j<�A��5��ܛ�Z89��Qa8�g^OBA�5j�xȠ�c�YZ#����e�a�O{T�r�yӿbz�E)}��L�G@և���z@jԨ�Py�,Dz^ßr�8�����F� vo�[�Ry����&a�R���/��PZT7ԨQ�ƃ���l�Y�?ވ�s7w2�1.���m��r��M�w0�-8 X?���� �Vִ_�F�� |;OՎ_A�F���tR�y[y�w�r����o�k�xnk��9�s�>K�ገ�Ɯ��0�H Η5�רQ㡂��y��:JRNg����\����ONG��j?o��ށ@�l9h�����=��'�|��'/��t����|�U[����jԨQ��@�l幖"1N����|��+����љ�lA�U� ���7pe�(�s"*<e;�-��g��O9~$��ee��P���Q��C�L��HF|��+���V�� T;3Z)Yh��,�wڳ��:RW:V��gY,c��P � �Oz�?}|L��j}��F�� �Q�F�7�qE�-�-S�G?��_?��(j��P�$аiS�h��]� ����rAl��aD!EjM����ο{����l1n��n�Q��C .W*� �V����F�l��}Y�F�A!mhF���Z4�Q� �!�tr�D���r�H�����5g�ks�e�[gS�TwըQ�ƃҹ�#�o�������'B���-\ �V�R�T�Q���ߓA ]�4H?��6�-�o�/8��/�{�am��F}�Y�".�i�F."ݩ�v�H9�2��IiD��0��)���(�nD*.ߥ���N�v����K&(��Y�"j���j�Z)�UP�*�L��ʜc<����6��r�S� )m@�h��Gغf��g<k��_sFK��|;¨Q�F�� �1:O�g>��^:�w��U�ȥ�Q+2��:�e6M�̬�:QaӉ$�1�B52T����Mi��%�4p[�b��Fe���k�cI�6�,ʢ�:NY�Á�ր�����t A�A���|�0��N�H -��|�=p��q.j��B��+p��*�r��(�P5���m �@l���B��c�](���bP�l����]��]w�R����5j�x�@9�/��~��̀�5x6��E� 0ȳ7��4��da�)A�*+�L�0�i���������B������ (��$e�D�4nA�r�0:��n�����d�[���J�]��G D��dF}"$4RdJ �7�~�Ғ;��` ���� ?)��,G@� �o�����ġH���($�YB;t�S�2�[�@[�Q�JC��~r��ߺh���A=��F�!Ȟq��:��7�x"/����� �d�=���ؔ�(� ���_J�%��7�� o'��K�Ȼ��-���Q)]���בm��M�Q����6�U�B]FȆrPi)�@D:�Y�H�U� L��qNU�E������y�a��a)S:��d�� �G�N%\����# �f����[���.S�h�"���x��r`3�P��Y�F��� w���w��S>