質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

プラグイン

プラグイン(plug-in)は、ソフトウェアアプリケーションの機能拡張の為に開発された、一組のソフトウェアコンポーネントのことを指します。

Q&A

0回答

1906閲覧

wordpressのプラグインであるwoocommerceのカスタマイズ

135

総合スコア8

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

プラグイン

プラグイン(plug-in)は、ソフトウェアアプリケーションの機能拡張の為に開発された、一組のソフトウェアコンポーネントのことを指します。

0グッド

0クリップ

投稿2019/09/17 06:30

現在wordpressのプラグインであるwoocommerceを使用し、ECサイトを作成しているのですが、支払いページの文を変えたいと思い、固定ページを見てみるとショートコード一行のみで書かれておりました。そこで、いろいろ探したところ、woocommerceのファイルでclass-wc-shortcode-my-accountというファイルがありその中身が以下のようになっていました。しかし、ショートコードの中身が書いておらず、困っております。どなたかわかる方いらっしゃいましたらよろしくお願いいいたします。

php

1<?php 2/** 3 * Checkout Shortcode 4 * 5 * Used on the checkout page, the checkout shortcode displays the checkout process. 6 * 7 * @package WooCommerce/Shortcodes/Checkout 8 * @version 2.0.0 9 */ 10 11defined( 'ABSPATH' ) || exit; 12 13/** 14 * Shortcode checkout class. 15 */ 16class WC_Shortcode_Checkout { 17 18 /** 19 * Get the shortcode content. 20 * 21 * @param array $atts Shortcode attributes. 22 * @return string 23 */ 24 public static function get( $atts ) { 25 return WC_Shortcodes::shortcode_wrapper( array( __CLASS__, 'output' ), $atts ); 26 } 27 28 /** 29 * Output the shortcode. 30 * 31 * @param array $atts Shortcode attributes. 32 */ 33 public static function output( $atts ) { 34 global $wp; 35 36 // Check cart class is loaded or abort. 37 if ( is_null( WC()->cart ) ) { 38 return; 39 } 40 41 // Backwards compatibility with old pay and thanks link arguments. 42 if ( isset( $_GET['order'] ) && isset( $_GET['key'] ) ) { // WPCS: input var ok, CSRF ok. 43 wc_deprecated_argument( __CLASS__ . '->' . __FUNCTION__, '2.1', '"order" is no longer used to pass an order ID. Use the order-pay or order-received endpoint instead.' ); 44 45 // Get the order to work out what we are showing. 46 $order_id = absint( $_GET['order'] ); // WPCS: input var ok. 47 $order = wc_get_order( $order_id ); 48 49 if ( $order && $order->has_status( 'pending' ) ) { 50 $wp->query_vars['order-pay'] = absint( $_GET['order'] ); // WPCS: input var ok. 51 } else { 52 $wp->query_vars['order-received'] = absint( $_GET['order'] ); // WPCS: input var ok. 53 } 54 } 55 56 // Handle checkout actions. 57 if ( ! empty( $wp->query_vars['order-pay'] ) ) { 58 59 self::order_pay( $wp->query_vars['order-pay'] ); 60 61 } elseif ( isset( $wp->query_vars['order-received'] ) ) { 62 63 self::order_received( $wp->query_vars['order-received'] ); 64 65 } else { 66 67 self::checkout(); 68 69 } 70 } 71 72 /** 73 * Show the pay page. 74 * 75 * @throws Exception When validate fails. 76 * @param int $order_id Order ID. 77 */ 78 private static function order_pay( $order_id ) { 79 80 do_action( 'before_woocommerce_pay' ); 81 82 $order_id = absint( $order_id ); 83 84 // Pay for existing order. 85 if ( isset( $_GET['pay_for_order'], $_GET['key'] ) && $order_id ) { // WPCS: input var ok, CSRF ok. 86 try { 87 $order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok. 88 $order = wc_get_order( $order_id ); 89 $hold_stock_minutes = (int) get_option( 'woocommerce_hold_stock_minutes', 0 ); 90 91 // Order or payment link is invalid. 92 if ( ! $order || $order->get_id() !== $order_id || ! hash_equals( $order->get_order_key(), $order_key ) ) { 93 throw new Exception( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ) ); 94 } 95 96 // Logged out customer does not have permission to pay for this order. 97 if ( ! current_user_can( 'pay_for_order', $order_id ) && ! is_user_logged_in() ) { 98 echo '<div class="woocommerce-info">' . esc_html__( 'Please log in to your account below to continue to the payment form.', 'woocommerce' ) . '</div>'; 99 woocommerce_login_form( 100 array( 101 'redirect' => $order->get_checkout_payment_url(), 102 ) 103 ); 104 return; 105 } 106 107 // Logged in customer trying to pay for someone else's order. 108 if ( ! current_user_can( 'pay_for_order', $order_id ) ) { 109 throw new Exception( __( 'This order cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ) ); 110 } 111 112 // Does not need payment. 113 if ( ! $order->needs_payment() ) { 114 /* translators: %s: order status */ 115 throw new Exception( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ) ); 116 } 117 118 // Ensure order items are still stocked if paying for a failed order. Pending orders do not need this check because stock is held. 119 if ( ! $order->has_status( wc_get_is_pending_statuses() ) ) { 120 $quantities = array(); 121 122 foreach ( $order->get_items() as $item_key => $item ) { 123 if ( $item && is_callable( array( $item, 'get_product' ) ) ) { 124 $product = $item->get_product(); 125 126 if ( ! $product ) { 127 continue; 128 } 129 130 $quantities[ $product->get_stock_managed_by_id() ] = isset( $quantities[ $product->get_stock_managed_by_id() ] ) ? $quantities[ $product->get_stock_managed_by_id() ] + $item->get_quantity() : $item->get_quantity(); 131 } 132 } 133 134 foreach ( $order->get_items() as $item_key => $item ) { 135 if ( $item && is_callable( array( $item, 'get_product' ) ) ) { 136 $product = $item->get_product(); 137 138 if ( ! $product ) { 139 continue; 140 } 141 142 if ( ! apply_filters( 'woocommerce_pay_order_product_in_stock', $product->is_in_stock(), $product, $order ) ) { 143 /* translators: %s: product name */ 144 throw new Exception( sprintf( __( 'Sorry, "%s" is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name() ) ); 145 } 146 147 // We only need to check products managing stock, with a limited stock qty. 148 if ( ! $product->managing_stock() || $product->backorders_allowed() ) { 149 continue; 150 } 151 152 // Check stock based on all items in the cart and consider any held stock within pending orders. 153 $held_stock = ( $hold_stock_minutes > 0 ) ? wc_get_held_stock_quantity( $product, $order->get_id() ) : 0; 154 $required_stock = $quantities[ $product->get_stock_managed_by_id() ]; 155 156 if ( $product->get_stock_quantity() < ( $held_stock + $required_stock ) ) { 157 /* translators: 1: product name 2: quantity in stock */ 158 throw new Exception( sprintf( __( 'Sorry, we do not have enough "%1$s" in stock to fulfill your order (%2$s available). We apologize for any inconvenience caused.', 'woocommerce' ), $product->get_name(), wc_format_stock_quantity_for_display( $product->get_stock_quantity() - $held_stock, $product ) ) ); 159 } 160 } 161 } 162 } 163 164 WC()->customer->set_props( 165 array( 166 'billing_country' => $order->get_billing_country() ? $order->get_billing_country() : null, 167 'billing_state' => $order->get_billing_state() ? $order->get_billing_state() : null, 168 'billing_postcode' => $order->get_billing_postcode() ? $order->get_billing_postcode() : null, 169 ) 170 ); 171 WC()->customer->save(); 172 173 $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); 174 175 if ( count( $available_gateways ) ) { 176 current( $available_gateways )->set_current(); 177 } 178 179 wc_get_template( 180 'checkout/form-pay.php', 181 array( 182 'order' => $order, 183 'available_gateways' => $available_gateways, 184 'order_button_text' => apply_filters( 'woocommerce_pay_order_button_text', __( 'Pay for order', 'woocommerce' ) ), 185 ) 186 ); 187 188 } catch ( Exception $e ) { 189 wc_print_notice( $e->getMessage(), 'error' ); 190 } 191 } elseif ( $order_id ) { 192 193 // Pay for order after checkout step. 194 $order_key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : ''; // WPCS: input var ok, CSRF ok. 195 $order = wc_get_order( $order_id ); 196 197 if ( $order && $order->get_id() === $order_id && hash_equals( $order->get_order_key(), $order_key ) ) { 198 199 if ( $order->needs_payment() ) { 200 201 wc_get_template( 'checkout/order-receipt.php', array( 'order' => $order ) ); 202 203 } else { 204 /* translators: %s: order status */ 205 wc_print_notice( sprintf( __( 'This order&rsquo;s status is &ldquo;%s&rdquo;&mdash;it cannot be paid for. Please contact us if you need assistance.', 'woocommerce' ), wc_get_order_status_name( $order->get_status() ) ), 'error' ); 206 } 207 } else { 208 wc_print_notice( __( 'Sorry, this order is invalid and cannot be paid for.', 'woocommerce' ), 'error' ); 209 } 210 } else { 211 wc_print_notice( __( 'Invalid order.', 'woocommerce' ), 'error' ); 212 } 213 214 do_action( 'after_woocommerce_pay' ); 215 } 216 217 218

関係がありそうな箇所だけぬきだしました。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

CHERRY

2019/09/17 14:08

どのようなメッセージを変更したいのでしょうか? WordPress やプラグインやテーマのディレクトリの中で、変更したいメッセージを検索してみるとどこかに記載されていないでしょうか?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問