Xstore主题下Waitlist插件简单商品缺货显示异常求助
问题详情
我使用Xstore主题搭建网站,安装Waitlist插件后,可变商品(Variable Product)的缺货等待功能运行正常,但简单商品(Simple Product)缺货时,“缺货(Out of stock)”标签、提示文字及订阅按钮会错误显示在页面头部上方。尝试用CSS修复无效,主题仅在商品描述区域有默认缺货提示,无库存等待列表专属设置。
插件相关代码
if( $isVariation ) { $is_oos = $this->productStock_quantity( $_product->get_parent_id(), $_product->get_id(), false ) ? false : true; $bo = $_product->get_backorders(); if( $is_oos && ( !$based_on_quantity || !in_array( $bo, array( 'yes', 'notify' ) ) || $subscibe_backorders_setting ) ) { $display_variationOutOfStock = true; } } else { $is_oos = $this->productStock_quantity( $_product->get_id(), 0, false ) ? false : true; $bo = $_product->get_backorders(); if( $is_oos && ( !$based_on_quantity || !in_array( $bo, array( 'yes', 'notify' ) ) || $subscibe_backorders_setting ) ) { $display_outOfStock = true; } } $display_msg = $availability['availability']; $display_classes = " stock in-msg " . $availability['class'] . " "; $notify_msg = ""; $verified_code = get_option('woowaitlist_product_verified_code') ? trim(get_option('woowaitlist_product_verified_code')) : ''; $is_active_license = $verified_code == '' ? 0 : 1; $form_fields = ''; if( is_user_logged_in() ) { $form_fields .= '<button id="wew-submit-email-to-notify" class="add_to_cart_button logged button">' . $this->get_subscribe_button_str() . '</button>'; } else { $form_fields .= '<input type="text" name="wew-email-to-notify" class="wew-email-to-notify" placeholder="' . $this->get_email_placeholder_str() . '" />'; $tStr = $this->get_subscribe_button_str() != '' ? $this->get_subscribe_button_str() : __( "Subscribe", 'woocommerce-waitlist' ); $form_fields .= '<button id="wew-submit-email-to-notify" class="add_to_cart_button button">' . $tStr . '</button>'; } $form_fields .= '<img class="wew-spinner" src="' . admin_url( 'images/spinner.gif' ) . '" />'; if( !$isVariation && ( ( $display_outOfStock && $this->get_hc() == 0 ) || ( $display_outOfStock && $this->get_hc() > 0 && $isGrouped ) ) ) { if( $this->get_hc() == 0 || ( $this->get_hc() > 0 && $isGrouped ) ){ if( $isGrouped ){ $oosType = "grouped"; } else{ $oosType = "stock"; } ?> <input type="hidden" class="wew-id-for-notify" value="<?php echo $_product->get_id(); ?>" /> <input type="hidden" name="wew-has-lic" id="wew-has-lic" value="<?php echo esc_attr( $is_active_license ); ?>" /> <?php if( $this->get_hc() == 0 ){ if( $isGrouped ){ ?> <input type="hidden" id="oos-parentid" value="<?php echo esc_attr( $_product->get_parent_id() ); ?>" /><?php } ?> <input type="hidden" id="oos-type" value="<?php echo esc_attr( $oosType ); ?>" /> <input type="hidden" name="wew-is-logged-in" id="wew-is-logged-in" value="<?php echo is_user_logged_in(); ?>" /><?php } } if( $is_active_license ) { if( in_array( $bo, array( 'yes', 'notify' ) ) ) { $display_msg = $availability['availability']; $display_classes = " stock in-msg " . $availability['class'] . " "; echo '<p class="'.$display_classes.'">'.$display_msg.'</p>'; } else { $display_msg = get_option('wew-out-of-stock-str') ? get_option('wew-out-of-stock-str') : __( 'Out of stock', 'woocommerce-waitlist' ); $display_classes = " stock out-msg " . $availability['class'] . " "; echo '<p class="'.$display_classes.'">'.$display_msg.'</p>'; $notify_msg = get_option('wew-out-of-stock-message') ? get_option('wew-out-of-stock-message') : __( 'Notify me when item is back in stock', 'woocommerce-waitlist' ); echo '<p class="oos-message">' . $notify_msg . '</p>'; } $display_form = '<div class="wew-notification-action_wrapper">' . $form_fields . '</div>'; echo $display_form; } else { echo '<p><strong>' . __( "WooWaitlist Activation Pending", 'woocommerce-waitlist' ) . '</strong></p>'; } $this->set_hc( intval( $this->get_hc() ) + 1 ); remove_filter( 'woocommerce_get_availability', array( $this, 'wew_check_product_availability' ) ); return; } elseif( $isVariation && !$display_outOfStock ) { if( $this->get_hc() == 0 ){ $oosType = "variation"; ?> <input type="hidden" id="oos-type" value="<?php echo esc_attr( $oosType ); ?>" /> <input type="hidden" class="wew-id-for-notify" value="<?php echo $_product->get_parent_id(); ?>" /> <input type="hidden" name="wew-is-logged-in" id="wew-is-logged-in" value="<?php echo is_user_logged_in(); ?>" /> <input type="hidden" name="wew-has-lic" id="wew-has-lic" value="<?php echo esc_attr( $is_active_license ); ?>" /><?php } if( $display_variationOutOfStock ) { // variation has NOT stock $cntv = 0; $variation_title = ""; if( !$this->is_ajax() ) { $form_fields = ''; } if( in_array( $bo, array( 'yes', 'notify' ) ) ) { $display_msg = trim( $availability['availability'] ) != '' ? $availability['availability'] : ''; $display_classes = $availability['class']; } else { $display_msg = get_option('wew-out-of-stock-str') ? get_option('wew-out-of-stock-str') : __( 'Out of stock', 'woocommerce-waitlist' ); $display_classes = " stock out-msg " . $availability['class'] . " "; $notify_msg = get_option('wew-variations-out-of-stock-message') ? get_option('wew-variations-out-of-stock-message') : __( 'Notify me when item variation is back in stock', 'woocommerce-waitlist' ) ; $display_msg .= '<p class="oos-message">' . $notify_msg . '</p>'; } $display_msg .= '<div class="wew-notification-action_wrapper variations">' . $form_fields . '</div>'; } $this->set_hc( intval( $this->get_hc() ) + 1 ); } $availability['availability'] = $display_msg ; $availability['class'] = $display_classes; $hidden_fields_output = ob_get_clean(); if( !$this->is_ajax() ) { echo $hidden_fields_output; } } remove_filter( 'woocommerce_get_availability', array( $this, 'wew_check_product_availability' ) ); return $availability; }
显示状态差异
- 可变商品:缺货提示及订阅按钮正常显示在商品详情区域内
- 简单商品:缺货标签、提示及订阅按钮错误显示在页面头部上方
网站域名:drop.com.br
内容的提问来源于stack exchange,提问作者Mateus Cardoso
相关产品推荐
相关产品推荐

