WC_Product::get_gallery_attachment_ids is deprecated since version 3.0

房东的猫 提交于 2021-02-10 12:52:26

问题


When define('WP_DEBUG', true); and my php code

<div class="col-md-5 col-sm-5 mb-xs-30"><?php // echo single_product_summary_sale_flash();?>
  <div class="fotorama" data-nav="thumbs" data-allowfullscreen="native"> 

    <a href="#"> <?php the_post_thumbnail(); ?> </a>

        <?php 
           global $product;

            $attachment_ids = $product->get_gallery_attachment_ids();

            foreach( $attachment_ids as $attachment_id ) {
                $image_link = wp_get_attachment_url( $attachment_id ); ?>

                    <a href="#"><img src="<?php echo $image_link;?>" alt="Xpent Super Shop "></a> 


                <?php  }
            ?>
      </div>
    </div>

i can see a Notice, that is Notice: WC_Product::get_gallery_attachment_ids is deprecated since version 3.0! Use WC_Product::get_gallery_image_ids instead. in D:\XAMPP\htdocs\wp\woocom\wp-includes\functions.php on line 3839 "

How to solve this problem ?


回答1:


problem solved .. just replace

$attachment_ids = $product->get_gallery_attachment_ids();

with

$attachment_ids =  $product->get_gallery_image_ids();



回答2:


open file /plugins/woocommerce/includes/legacy/abstract-wc-legacy-product.php

just comment wc_deprecated_function( 'WC_Product::get_gallery_attachment_ids', '3.0', 'WC_Product::get_gallery_image_ids' );

at line no 175.

And Enjoy



来源:https://stackoverflow.com/questions/50305855/wc-productget-gallery-attachment-ids-is-deprecated-since-version-3-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!