ECサイトをゼロから構築して、様々な商品を販売したいと考えている方もいるかもしれません。あるいは、ここ数年ECサイトを運営していて、視野を広げて新しい商品を販売したいと考えている方もいるかもしれません。このチュートリアルをご覧になった理由は何であれ、WooCommerceをカスタマイズする必要があるのは事実です。Bright Vesselには、必要な情報がすべて揃っています!
WooCommerce is the most popular WordPressプラグイン for eCommerce and the preferred solution for a lot of sellers. Why? It’s free and also highly versatile, as it’s effortless to customize WooCommerce to fit your needs. While the plugin offers a series of set options, there’s a lot you can do from its backstage.
Bright Vesselの多くのお客様は、それぞれのビジネスのニュアンスを考慮した、独自のeコマースソリューションを求めています。WooCommerceに関する豊富な経験を活かし、お客様のニーズに合わせたeストアの構築をお手伝いいたします。さあ、始めましょう!
Below, you’ll find the basic setup you’ll need to customize WooCommerce:
ただし、WooCommerceのカスタムフィールドはWordPressのカスタムフィールドとは少し異なります。WordPressでは投稿のメタデータを扱うと定義されていますが、ここでは「カスタムフィールド」を実際のテキストフィールドとして扱います。WooCommerceメニューで、「Simple Products」タイプの「Linked Products」タブに移動します。
There’s a critical WordPress concept we need to get out of the way before delving into how to customize WooCommerce: Hooks. According to WPBeginner, Hooks are “functions applicable to an Action or a Filter in WordPress. Actions and Filters in WordPress are functions that you can modify by theme and plugin developers to change the default WordPress functionality.”
WooCommerceは、ユーザーがページのライフサイクルにアクセスできるようにするAPIを提供しています。ただし、WooCommerce APIはWordPressのメタデータAPIとは少し異なります。知っておくべき主なフックが2つあります。
これらのフックを使用するには、フックを定義して機能をカスタマイズする必要があります。
フックに 2 つのカスタム関数を登録する初期化関数を追加することで、上記のフックを使用できるようになりました。
テキスト入力フィールドを追加するには、まず woocommerce_product_options_grouping にフックされた関数を追加する必要があります。
To implement the function, you should:
上記の情報は関連配列に格納され、woocommerce_wp_text_input に渡されます。WooCommerce をカスタマイズするためのこの API 関数は、入力した情報を含むテキスト要素を出力します。
To save the changes above, you’ll need to:
To render information on the front-end, you’ll need to create a new class. You’ll specifically need:
テキスト フィールド ID とそれをコンストラクターで初期化します。
WooCommerceのカスタマイズ方法に関するこのチュートリアルはほぼ完了です!最後のステップは、最新の変更をすべて反映したプラグインを起動するためのブートストラップファイルの設定です。起動用のコードは次のとおりです。
A couple of extra notes:
Now that you know how to customize WooCommerce to add your fields to simple products, you’re on your way to providing exactly the services you want to deliver. You can find more WooCommerceチュートリアル on our blog. If you’re looking for experts who know how to work around this popular eCommerce plugin, お問い合わせ for more information!
"*" indicates required fields
"*" indicates required fields
"*" indicates required fields
You must be ログイン to post a comment.