WooCommerce。如何使用(do_shortcode)在单个产品页面中打开产品页面?

时间:2019-08-08 21:34:58

标签: php woocommerce

我有一个来自WooCommerce插件的产品页面,当我尝试将此产品页面添加到主题的单个页面时,它不会出现。

我正在使用以下代码:

df <- data.frame(a = 1:5, b=11:15, c=21:25)

# define function with if-else statement to catch any possible duplicates
addnew <- function(data,name='newvar'){
  if(sum(grepl(name,names(data),ignore.case=T))>0)
  {stop('Error! Possible duplicate names with your new variable names')} else{
  data1 <- data %>% mutate_all(list( ~ runif(n())))
  names(data1) <- paste0(names(data1),'_',name)
  bind_cols(data,data1)
    }
}

addnew(df,'new')

  a  b  c     a_new     b_new     c_new
1 1 11 21 0.2875775 0.0455565 0.9568333
2 2 12 22 0.7883051 0.5281055 0.4533342
3 3 13 23 0.4089769 0.8924190 0.6775706
4 4 14 24 0.8830174 0.5514350 0.5726334
5 5 15 25 0.9404673 0.4566147 0.1029247

# try with new data that should throw an error
df <- data.frame(a_new = 1:5,b=11:15,c=21:25)

addnew(df,'new')
Error in addnew(df, "new") : 
  Error! Possible duplicate names with your new variable names

如果我将此代码添加到<?php echo do_shortcode( '[product_page id="2279"]' );?> ,它将起作用:

single-game.php

但是,当我尝试向<div id="primary" class="content-area"> <div class="inner"> <?php $posts = tfuse_get_game_news($post->ID);?> <?php echo do_shortcode( '[product_page id="2279"]' );?> <?php if(get_option('posts_per_page') < count($posts)):?> <div class="load_button"> <button type="submit" class="btn btn-main" id="load_game_posts" data-post-id="<?php echo $post->ID;?>" data-from="game_buyy" value=""><?php _e('Load More', 'tfuse'); ?></button> <button type="submit" class="btn btn-main" id="loading_game_posts"><?php _e('Loading...', 'tfuse'); ?></button> </div> <?php endif;?> </div> </div> 文件中添加相同的代码时:

AJAX_CALLBACKS.php

我黑屏了,没有任何东西。

我尝试了以下代码:

elseif($tax == 'game_buy')
    {
        $posts = tfuse_get_game_posts($post_id,'Buy Now');

        echo do_shortcode( '[product_page id="2279"]' );

    }

我希望当我单击“立即购买”按钮时,它将显示我的产品。

0 个答案:

没有答案