正确更新content-single-product.php文件

时间:2019-05-22 03:37:11

标签: woocommerce

我已经使产品页面看起来像我希望它浏览content-single-product.php文件,但是它与插件冲突。我想我可能已经犯了一个错误,或者编码效率不高,所以我在这里添加编码,以查看如何改进或是否应该以其他方式进行编码

我最近更新了woocommerce,并注意到我的编码可能不适合该页面。我已经添加了一些东西来使单个产品页面显示我想要的方式,但是我想我可以用另一种方式来实现。寻找改进我的代码的建议。运行php 7.2 wp 5.2.1 woocommerce 3.6.3。

`

   <?php
/**
 * The template for displaying product content in the single-product.php template
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates
 * @version 3.6.0
 */

defined( 'ABSPATH' ) || exit;

global $product;

/**
 * Hook: woocommerce_before_single_product.
 *
 * @hooked wc_print_notices - 10
 */
do_action( 'woocommerce_before_single_product' );

if ( post_password_required() ) {
    echo get_the_password_form(); // WPCS: XSS ok.
    return;
}
?>
<div id="product-<?php the_ID(); ?>" <?php wc_product_class( '', $product ); ?>>


<div class="container-fluid">

    <!-- Breadcrumbs Start -->
        <!--<div class="row">
            <div class="col-sm-12 pb-4">
                <?php do_action( 'woocommerce_before_main_content' ); ?>
                <hr>
            </div>
        </div>-->
        <!-- Breadcrumbs End -->

        <!-- Images and product info -->
        <div class="row">

            <!-- Product Image and Sharing Start --> 
            <div class="col-lg-5 col-sm-12">
                <div class="row">
                    <div class="col-sm-12 text-center m-auto align-center w-100">
                        <?php do_action( 'woocommerce_before_single_product_summary' ); ?>
                    </div>
                      <div class="col-sm-12 "style="margin-top:3%;"">
                        <?php echo do_shortcode('[share title="Share this Product" facebook="true" linkedin="true" twitter="true" google_plus="False"  pinterest="false" reddit="false" email="true"]'); ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12"style="margin-top:3%;">
                        <?php do_action( 'woocommerce_single_product_summary_sharing' ); ?>
                    </div>
               </div>
            </div>
            <!-- Product Image and Sharing End -->

            <!-- Product Info Start -->
            <div class="col-lg-7 col-sm-12">
                <div class="row">
                    <div class="col-sm-12 mt-3">
                        <?php do_action( 'woocommerce_single_product_title' ); ?>
                        <hr>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <?php do_action( 'woocommerce_single_product_summary_meta'); ?>
                        <hr>
                    </div>
                    <div class="col-sm-12">
                        <?php do_action('woocommerce_single_product_summary_price'); ?>
                    </div>
                    <div class="col-sm-12">
                        <?php do_action( 'woocommerce_single_product_summary_excerpt'); ?>
                    </div>
                    <div class="col-sm-12">
                        <?php do_action( 'woocommerce_single_product_summary' ); ?>
                    </div>
                </div>
                <div class="row">

                </div>
                <div class="row">

                </div>
                <div class="row">
                    <div class="col-sm-8" style="margin-top:4%;">
                        <?php echo do_shortcode('[ti_wishlists_addtowishlist]'); ?>
                    </div>   
                </div>
            </div>
        </div>
                <div class="row">

                </div>

                    <!-- Product Info End -->





         <!-- Images and Product Info End -->

        <!-- Section Contact | Additional Information -->
        <div class="row py-4">
            <div class="col-lg-4 col-sm-12">
                <div class="p-3" style="border:solid thin #71a634; background: #FFFF; border-radius: 25px; margin-bottom: 2%;">
                            <center>
                        <p> <b>Cant find what you are looking for? Buying In Bulk or Large Orders ? </b></p><a class="x-btn btn-lg rounded" style="text-shadow:none;font-size:16px;" href="http://rodburn.com.au/get-a-quote">Request A Quote</a>
                            </center>
                </div>


                <div class="p-3" style="border:dashed thin #71a634;border-radius: 25px;">
                    <h4 class="text-green">Quick Product Information</h4>
                    <?php echo do_shortcode( '[contact-form-7 id="14448" title="Product Sidebar"]' ); ?>
                </div>
            </div>
            <div class="col-lg-8 col-sm-12">
                <div class="row">
                    <div class="col-sm-12">
                        <?php do_action( 'woocommerce_after_single_product_summary_tabs' ); ?>
                    </div>
                </div>
            </div>
                <div class="row">
                    <div class="col-sm-12">
                        <?php do_action( 'woocommerce_after_single_product_summary_upsell'); ?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <?php do_action( 'woocommerce_after_single_product_summary_related' ); ?>
                    </div>
                </div>
            </div>
        </div>
        <!-- END Contact | Additional Information -->




</div>           

<?php do_action( 'woocommerce_after_single_product' ); ?>

`

我遇到了一个名为WooCommerce的Product Inquiry Pro插件的问题,PEP使用以下selector.summary.entry-summary .variation_id:first-child我希望能够同时使用我的布局和插件。如果我提交文件,则插件可以工作,但修改失败。

0 个答案:

没有答案