Welcart basic の商品一覧ウィジェットについて

フォーラム 拡張プラグイン Welcart basic の商品一覧ウィジェットについて

  • このトピックには1件の返信、2人の参加者があり、最後にikedaにより1年、 10ヶ月前に更新されました。
2件の投稿を表示中 - 1 - 2件目 (全2件中)
  • 投稿者
    投稿
  • #97176
    Akuy
    参加者

    お世話になります。
    現在Welcart basicを親テーマに利用し、子テーマにてカスタマイズを行っています。

    Welcart 商品一覧ウィジェットに商品詳細(本文の抜粋)を表示したいのですが、
    「widgets」フォルダ内の「item-list.php」は子テーマのものは上書きされないので、
    子テーマのfunctions.phpに下記のコードにて親テーマの該当箇所を削除し、
    子テーマのものを読み込むようにしたのですが、Fatal errorになってしまいます。

    function remove_parent_theme_actions() {
    	remove_action( 'widgets_init', 'welcart_basic_widgets_init');
    }
    add_action( 'widgets_init', 'remove_parent_theme_actions' );
    add_action('widgets_init','welcart_basic_widgets_init_child');
    
    function welcart_basic_widgets_init_child() {
    	require get_stylesheet_directory() . '/widgets/item-list.php';
    
    	register_widget( 'Basic_Item_List' );
    
    	register_sidebar(
    		array(
    			'name'          => __( 'Home Left Widget', 'welcart_basic' ),
    			'id'            => 'left-widget-area',
    			'description'   => __( 'Widget area left of the top page footer top', 'welcart_basic' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<h3 class="widget_title">',
    			'after_title'   => '</h3>',
    		)
    	);
    
    	register_sidebar(
    		array(
    			'name'          => __( 'Home Center Widget', 'welcart_basic' ),
    			'id'            => 'center-widget-area',
    			'description'   => __( 'Widget area center of the top page footer top', 'welcart_basic' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<h3 class="widget_title">',
    			'after_title'   => '</h3>',
    		)
    	);
    
    	register_sidebar(
    		array(
    			'name'          => __( 'Home Right Widget', 'welcart_basic' ),
    			'id'            => 'right-widget-area',
    			'description'   => __( 'Widget area right of the top page footer top', 'welcart_basic' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<h3 class="widget_title">',
    			'after_title'   => '</h3>',
    		)
    	);
    	register_sidebar(
    		array(
    			'name'          => __( 'Sidebar Widget 1', 'welcart_basic' ),
    			'id'            => 'side-widget-area1',
    			'description'   => apply_filters( 'welcart_basic_side_widgetarea1_description', __( 'Widget area Product Details page or category page or search page', 'welcart_basic' ) ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<h3 class="widget_title">',
    			'after_title'   => '</h3>',
    		)
    	);
    
    	register_sidebar(
    		array(
    			'name'          => __( 'Sidebar Widget 2', 'welcart_basic' ),
    			'id'            => 'side-widget-area2',
    			'description'   => __( 'Widget area of posts and pages', 'welcart_basic' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<h3 class="widget_title">',
    			'after_title'   => '</h3>',
    		)
    	);
    }

    エラー内容
    Fatal error: Cannot declare class Basic_Item_List, because the name is already in use in 〜/wp-content/themes/welcart_basic/widgets/item-list.php on line 0

    この方法では商品一覧ウィジェットを編集できないのでしょうか?
    その他の方法で商品一覧ウィジェットに詳細を表示させる方法はありますでしょうか?

    ちなみにフックは出力される箇所が違うため(<article></article>内へ出力させたい)使用していません。
    よろしくお願い致します。

    #97187
    ikeda
    キーマスター

    Akuy 様
    こんにちは。
    「Basic_Item_List」が既に宣言されている(重複している)エラーですので、
    名前を変更する必要があるかと思います。
    もしくは、<article></article> 内へ抜粋を表示させたいとのことですので、welcart_basic_filter_item_postフックを使って
    <article></article> の出力内容自体を変更される方が簡単かと思います。

2件の投稿を表示中 - 1 - 2件目 (全2件中)
  • このトピックに返信するにはログインが必要です。