golden hour
/home/godaofbq/hardchambers.com/wp-content/plugins/quicker-pro/core/frontend
⬆️ Go Up
Upload
File/Folder
Size
Actions
ajax-action.php
4.56 KB
Del
OK
checkout-fees.php
4.42 KB
Del
OK
checkout-fields.php
5.43 KB
Del
OK
quick-view.php
2.76 KB
Del
OK
side-cart.php
3.26 KB
Del
OK
Edit: ajax-action.php
<?php namespace QuickerPro\Core\Frontend; use QuickerPro\Utils\Singleton; /** * Base Class * * @since 1.0.0 */ class AjaxAction { use Singleton; /** * Ajax action */ public function init() { $callback = ['quicker_update_mini_cart','quick_view']; if ( ! empty( $callback ) ) { foreach ( $callback as $key => $value ) { add_action( 'wp_ajax_' . $value, [$this, $value] ); add_action( 'wp_ajax_nopriv_' . $value, [$this, $value] ); } } } public function error_response($message = '' ){ $mes = empty($message) ? __( 'Required data missing', 'quicker-pro' ) : $message; return wp_send_json_success(array('message'=>$mes)); } public function send_success($message){ ob_start(); \QuickerPro\Core\Frontend\SideCart::instance()->side_cart(); $html = ob_get_clean(); $fragments['.quicker-container'] = '<div class="quicker-container">'.$html.'</div>'; $fragments['.quicker-cart-count'] = '<div class="quicker-cart-count">'.WC()->cart->get_cart_contents_count().'</div>'; return wp_send_json_success(array('message'=>$message,'fragments'=>$fragments)); } protected function verify_nonce() { $nonce = filter_input( INPUT_POST, 'nonce', FILTER_UNSAFE_RAW ); if ( is_null( $nonce ) || ! wp_verify_nonce( $nonce, 'quicker_pro' ) ) { wp_send_json( array( 'message' => __( 'Security check failed', 'quicker-pro' ), 'code' => 401 ) ); } } /** * Update mini cart qty * */ public function quicker_update_mini_cart() { $cart_key = isset( $_POST['cart_key'] ) ? sanitize_text_field( $_POST['cart_key'] ) : ''; if ( empty( $cart_key ) ) { $this->error_response(); } if ( is_null( WC()->cart ) ) { $this->error_response( __( 'Cart not defined', 'quicker-pro' ) ); } $cart_items = WC()->cart->get_cart(); if ( ! isset( $cart_items[ $cart_key ] ) ) { $this->error_response( __( 'Cart item not found', 'quicker-pro' ) ); } $cart_item = $cart_items[ $cart_key ]; $product = $cart_item['data']; add_filter( 'wp_redirect', '__return_false', 100 ); $quantity = isset( $_POST['quantity'] ) ? sanitize_text_field( $_POST['quantity'] ) : ''; $quantity = empty( $quantity ) ? 0 : floatval( $quantity ); /** If 0 qty set */ if ( 0 == $quantity || $quantity < 0 ) { WC()->cart->remove_cart_item( $cart_key ); $message = sprintf( __( '%s has been removed from your cart.', 'woocommerce' ), $product->get_name() ); $this->send_success( $message ); } if ( ! $product->has_enough_stock( $quantity ) ) { $message = sprintf( __( 'Sorry, you can not add more then %s of "%s". Please edit your cart and try again.', 'quicker-pro' ), $product->get_stock_quantity(), $product->get_name() ); $this->error_response( $message ); } $status = WC()->cart->set_quantity( $cart_key, $quantity ); if ( $status ) { $message = sprintf( __( '"%s" has been updated.', 'quicker-pro' ), $product->get_name() ); $this->send_success( $message ); } $product_qty_in_cart = WC()->cart->get_cart_item_quantities(); $current_session_order_id = ( isset( WC()->session->order_awaiting_payment ) ? absint( WC()->session->order_awaiting_payment ) : 0 ); $held_stock = wc_get_held_stock_quantity( $product, $current_session_order_id ); $required_stock = $product_qty_in_cart[ $product->get_stock_managed_by_id() ]; if ( $product->get_stock_quantity() < ( $held_stock + $required_stock ) ) { $message = sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ); $this->error_response( $message ); } $message = sprintf( __( 'Some error occurred in updating the "%s"', 'quicker-pro' ), $product->get_name() ); $this->error_response( $message ); } public function quick_view() { $product_id = isset( $_POST['product_id'] ) ? sanitize_text_field( $_POST['product_id'] ) : ''; $view_action = isset( $_POST['quick_view_action'] ) ? sanitize_text_field( $_POST['quick_view_action'] ) : ''; if ( !empty($product_id) && ( "variation_popup" == $view_action ) ) { \QuickerPro\Core\Frontend\QuickView::instance()->variation_popup_template( $product_id ); wp_send_json_success( ['success'=>1,'message'=>'success','data'=>json_encode(ob_get_clean())] ); }else{ $msg = $product_id == '' ? esc_html__('Product Id missing','quicker-pro') : esc_html__('Something is wrong','quicker-pro') ; wp_send_json_error( ['success'=>0,'message'=> $msg ,'data'=>array()] ); } wp_die(); } }
Save