我需要一些帮助才能在结帐页面上显示购物车中所有产品的加售,下面的代码给了我以下错误:
调用数组中的成员函数 get_upsell_ids()...
这是我的功能:
function show_cross_sell( $limit = '-1', $columns = 4, $orderby = 'rand', $order = 'desc' ) {
global $woocommerce;
$items = WC()->cart->get_cart();
if ( ! $items ) {
echo 'nothing';
return;
}
// Handle the legacy filter which controlled posts per page etc.
$args = apply_filters(
'woocommerce_upsell_display_args',
array(
'posts_per_page' => $limit,
'orderby' => $orderby,
'order' => $order,
'columns' => $columns,
)
);
foreach($items as $product) {
wc_set_loop_prop( 'name', 'up-sells' );
wc_set_loop_prop( 'columns', apply_filters( 'woocommerce_upsells_columns', isset( $args['columns'] ) …Run Code Online (Sandbox Code Playgroud)