Last active
December 29, 2020 11:19
-
-
Save Niloys7/1336c3bac9522822079be641e4b06e02 to your computer and use it in GitHub Desktop.
Since Porto theme has there owned gallery markup that reason the quick view feature is not working properly with the "product gallery slider" . so we need to override the ajax function only for the quick view mode.to do this just copy the code from below and paste it into your child-theme/functions.php or create a custom plugin to add this code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'cix_new_hooks'); | |
function cix_new_hooks(){ | |
remove_action( 'wp_ajax_porto_product_quickview', 'porto_product_quickview' ); | |
remove_action( 'wp_ajax_nopriv_porto_product_quickview', 'porto_product_quickview' ); | |
add_action( 'wp_ajax_porto_product_quickview', 'cix_porto_product_quickview' ); | |
add_action( 'wp_ajax_nopriv_porto_product_quickview', 'cix_porto_product_quickview' ); | |
} | |
function cix_porto_product_quickview() { | |
//check_ajax_referer( 'porto-nonce', 'nonce' ); | |
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification | |
global $post, $product; | |
$post = get_post( (int) $_REQUEST['pid'] ); | |
$product = wc_get_product( $post->ID ); | |
if ( post_password_required() ) { | |
echo get_the_password_form(); | |
die(); | |
return; | |
} | |
porto_woocommerce_add_js_composer_shortcodes(); | |
?> | |
<div class="quickview-wrap quickview-wrap-<?php echo esc_attr( $post->ID ); ?> single-product<?php echo ' product-type-' . esc_attr( $product->get_type() ); ?>"> | |
<div class="product product-summary-wrap"> | |
<div class="row"> | |
<div class="col-lg-6 summary-before"> | |
<?php | |
get_template_part('woocommerce/single-product/product-image'); | |
?> | |
</div> | |
<div class="col-lg-6 summary entry-summary"> | |
<?php | |
do_action( 'woocommerce_single_product_summary' ); | |
if ( ! isset( $_REQUEST['variation_flag'] ) || ! $_REQUEST['variation_flag'] || 'false' == $_REQUEST['variation_flag'] ) : | |
?> | |
<script> | |
<?php | |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
$assets_path = esc_url( str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) ) . '/assets/'; | |
$frontend_script_path = $assets_path . 'js/frontend/'; | |
?> | |
var wc_add_to_cart_variation_params = | |
<?php | |
echo array2json( | |
apply_filters( | |
'wc_add_to_cart_variation_params', | |
array( | |
'wc_ajax_url' => WC_AJAX::get_endpoint( '%%endpoint%%' ), | |
'i18n_no_matching_variations_text' => esc_js( __( 'Sorry, no products matched your selection. Please choose a different combination.', 'woocommerce' ) ), | |
'i18n_make_a_selection_text' => esc_js( __( 'Please select some product options before adding this product to your cart.', 'woocommerce' ) ), | |
'i18n_unavailable_text' => esc_js( __( 'Sorry, this product is unavailable. Please choose a different combination.', 'woocommerce' ) ), | |
) | |
) | |
) | |
?> | |
; | |
jQuery(document).ready(function($) { | |
$.getScript('<?php echo porto_filter_output( $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js' ); ?>'); | |
}); | |
</script> | |
<?php endif; ?> | |
</div><!-- .summary --> | |
</div> | |
</div> | |
</div> | |
<?php | |
// phpcs:enable | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment