2017-01-29 16 views
0

Easy Digital Downloadsプラグインで、チェックアウト、領収書、その他のページを編集したいと思います。そのdocumentationとして
が、私は私の現在のテーマのフォルダ/ edd_templatesにそのファイルをコピーした/
は実は、私は2の異なるカテゴリ(ワークショップ、ソフトウェア)を持っていると私はのためにを異なるテーブルを表示する方法を探していますこれらのカテゴリのすべての1つ1つのチェックアウトページ。私は、問題は、私はワードプレスに語っているということだと思いますWordpress - テーマのカスタムタクソノミーフィルタ?

<?php 
$args = array(
    'post_per_page' => '-1', 
    'post_type' => 'download', 
    'tax_query' => array(
     array(
      'taxonomy' => 'download_category', 
      'field' => 'slug', 
      'terms' => 'workshop' 
     ) 
) 
); 
$my_posts = get_posts($args); 
if ($my_posts) : 
?> 
// custom html table for first category goes here... // 
<?php endif; ?> 
<?php 
$args1 = array(
'post_per_page' => '-1', 
'post_type' => 'download', 
'tax_query' => array(
    array(
     'taxonomy' => 'download_category', 
     'field' => 'slug', 
     'terms' => 'software' 
    ) 
) 
); 
$myy_posts = get_posts($args1); 
if ($myy_posts) : 
?> 
// custom html table for second category goes here... // 
<?php endif; ?> 

しかし、それはチェックアウトページ、あなたがどのカテゴリに関係なく、両方のテーブルを示しています...

だから、私はこれを使用しようとしましたこれらのカテゴリに何かがある場合、これらのhtmlテーブルを表示するだけです。それらをフィルタリングしない...
どうすればこの問題を解決できますか?

答えて

0

あなたはこの多くの方法で解決することができ、私は、以下のいずれかをお見せアウト

<?php 
/** 
* Template Name: Checkout 
* 
*/ 

は、カスタムテンプレートファイルにコードを右のように、 まず、あなたの欲求ページのテンプレートページを作成します。 次に管理者用ダッシュボードにアクセスし、カスタムテンプレートのチェックアウトを選択します。ページがあなたの欲求の出力を表示します

enter image description here

0

あなたは最後の段落で正しくありますが、フィルタは一切置かれていません。まずカート内の製品のカテゴリを取得する必要があります。

<?php $cart_items = edd_get_cart_contents(); //get the contents in the cart 
foreach ($cart_items as $key => $item): ?> 

<?php 
$terms = wp_get_post_terms($item->ID, 'download_category'); //get the categories of the items in the cart 
foreach ($terms as $term) $categories[] = $term->slug; //form an array with those categories 

は、その後、あなたはそのカテゴリの配列は、あなたの用語を持っているかどうかを確認する必要があり

if (in_array('workshop', $categories)) { 
// custom html table for first category goes here... // 
}elseif (in_array('software', $categories)){ 
// custom html table for second category goes here... // 
else { 
// custom html table for regular downloads goes here... // 
}