• Community
  • Contact
    • Apply Contributor
  • Privacy Policy
    • Cookie Policy
2025/07/04 Friday
  • Login
  • Register
beKOUE
  • 日本語
  • 中文 (中国)
  • Español
  • Connecting
  • KOBE
  • Akashi
  • Technology
No Result
View All Result
beKOUE
  • Connecting
  • KOBE
  • Akashi
  • Technology
No Result
View All Result
beKOUE
No Result
View All Result
オンラインショップ|オーダーメイド

Home » 2023] woocommerce order history within Line

2023] woocommerce order history within Line

LIFF 第二章

管理者 by 管理者
2023/2/15
in Wordpress
0 0
A A
0
0
SHARES
331
VIEWS
ShareTweetスキャン

Table of Contents

  • 1. Retrieving order history with a single Hook
  • 2. Customizing Order History Retrieval Conditions
  • 3. Minimize the scope of order history operations
  • 4. User-friendly Auto Login
  • 5. Conclusion

Here is an example of displaying a woocommerce order history list in Line’s mini-appli “LIFF”, a feature briefly introduced in Chapter 1.

1 Retrieving order history with a single Hook

You can retrieve the entire order history by executing only the hook “woocommerce_account_orders_endpoint”.

protected function do_action()
{
	add_filter('woocommerce_my_account_my_orders_query', [$this, 'orders_query']);
	ob_start();
	do_action('woocommerce_account_orders_endpoint');
	$this->main_contents .= '<h3>注文履歴</h3>';
	$this->main_contents .= ob_get_clean();
	$this->main_contents .=
		sprintf(
			'<h5>直近の注文履歴から最大 %s 件を表示します。</h5>',
			self::ORDER_NUM_LIMIT
		);
	remove_filter('woocommerce_my_account_my_orders_query', [$this, 'orders_query']);
	return true;
}

2 Customizing Order History Retrieval Conditions

To display the history of a specific user in Line’s mini-application, which has a limited display area, it is inevitable to specify additional conditions.

Therefore, the filter hook “woocommerce_my_account_my_orders_query” is used to overwrite the search criteria.

public function orders_query($arg)
{
	$arg['customer'] = $this->user->ID; // 顧客を指定
	$arg['post_status'] = array('wc-processing', 'wc-completed'); // 注文ステータスを指定
	$arg['limit'] = self::ORDER_NUM_LIMIT; // 最大取得件数を指定
	return $arg;
}

3 Minimize the scope of order history operations

The hook “woocommerce_account_orders_endpoint” is only an action used for the endpoint “myaccount” web page. For example, in the case of in the case of “myaccount”, we have a case where multiple buttons appear at the same time in the “operation” field, such as “display, invoice, delivery note, payment method, etc.”. Since the area for mini-applications is limited, let’s just use “View (.view)”.

オンラインショップ|ダンス|スポーツ|専門店
.woocommerce-button:not(.view){
  /*表示ボタン以外の操作は非表示*/
  display: none;
} 

4 User-friendly Auto Login

The order history list in Line is displayed. If you want to check the details of your history in Line, you have to intervene by logging in to the site. If you have obtained a Line idToken and have identified the user, you can have the user log in automatically at the same time when displaying the order details in the Line.

Extract the URL specified as endpoint “myaccount” with preg_match_all and convert it to an automatic login URL in a batch.

protected function set_mypage_auto_linelogin()
{
	$pattarn = str_replace(['/', '.'], ['/', '.'], wc_get_page_permalink('myaccount')); // endpoint「myaccount」のURLを正規表現に
	$pattarn = '/href="' . $pattarn . '(.*?)"/i';
	if (preg_match_all($pattarn, $this->main_contents, $matched_url)) {
		$replace_from = array();
		$replace_to = array();
		foreach ($matched_url[0] as $index => $url) {
			$replace_from[] = $matched_url[1][$index];
			$replace_to[] = $this->line_login->get_auto_linelogin_url($matched_url[1][$index]);
		}
		$this->main_contents = str_replace($replace_from, $replace_to, $this->main_contents);
	}
}

5 Conclusion

If online store orders can be displayed in Line with a single click, the service will be improved and trust in the store will increase.

Soccer | Physical | Rokko Island | Kids | Toddler Gymnastics

Previously, user information was acquired in the form of bot mode (Messaging API) steps, but from June 2023, the free limit for pot mode (Messaging API) will be reduced from 1000 to 200 messages. Shifting to mini-applications (LIFF) may be an option.

And if you are looking for more detailed source code or interested in LIFF development and want to exchange opinions about LIFE, please log in and leave a comment.

Tags: LIFFLinePHPWoocommerce 7
ShareTweetScan
MeIN|Akashi|Futami|Kids|Dance|Since 2016
Previous Post

LIFF: Mass Inheritance, Therefore, Front Reuse

Next Post

Kobe City: “Nighttime Opening of Junior High School Gymnasiums Utilizing ICT” Target Schools from February

管理者

管理者

The author was born in China in 1985. After graduating from university in 2008, he got a job at a Japanese company in China. After moving to the head office in Tokyo in 2011, he contributed to the company as a system engineer and programmer, mainly subcontracting from major Japanese companies. At the same time, he is improving his Japanese, various programming and language skills. In 2016, he traveled around the world as the last turning point in his twenties. After experiencing a wide variety of cultures, he moved to the undeveloped land of Kansai, determined to restart everything from scratch. He opened bekoue.com equipped with all the technology cultivated in IT in order to transmit the big city of Kobe to the world. He is sending out the charm of Kansai and Kobe to the world every day.

Related Posts

Wordpress

Line Woocommerce Circulation System Online

2023/4/13
0
144

About coupon tickets There are many occasions in the world where you can use coupon tickets, such as for bathing at a super public bath, bus tickets, event tickets, and so on. With the cooperation of Gooall, a sports school (hereinafter referred to as "Gooall"), we would like to introduce an online coupon system that has been put into practical use with Line & woocommerce. First, the online frequency system. Before introducing the system, we will briefly explain how it works in Gooall's paper-based system. Students themselves select...

Read more
【2023年版】LIFF 量産 継承 よって フロント再利用

LIFF: Mass Inheritance, Therefore, Front Reuse

2023/2/15
200
【2023年版】Woocommerce 注文 受け Lineへ電子レシートを送信

[2023] Woocommerce Order Received Electronic Receipt to Line

2023/2/15
190
Next Post
神戸市:「ICTを活用した中学校体育館の夜間開放」2月から対象校

Kobe City: "Nighttime Opening of Junior High School Gymnasiums Utilizing ICT" Target Schools from February

学生アメフトの聖地の芝生がメリケンパークに! メリケンパークに

The Lawn at the Sacred Place of Student Football in Meriken Park! The Koshien Bowl is the final game of the All-Japan University American Football Championship Tournament.

Please login to join discussion

Popular

  • Tanabata Festival” at Kobe University: Stage Event and Fireworks Launch – Kobe Keizai Shimbun

    0 shares
    Share 0 Tweet 0
  • Nostalgic Characters from the Showa Era! Sanrio Exhibition at the Museum of Contemporary Art Kobe

    0 shares
    Share 0 Tweet 0
  • 11th Hydrangea Festival” at Sumiyoshi Shrine in Uozumi to be held on June 22

    0 shares
    Share 0 Tweet 0
  • Kobe City : Higashinada Fire Station Organization (Main Station & Sub-branches)

    0 shares
    Share 0 Tweet 0
  • Don’t miss the world’s best gold award-winning performance! Port Island

    0 shares
    Share 0 Tweet 0

Newest

夏休み自由研究応援講座②「『なぜ?』を見つける動物園!~動物  2025

Summer Holiday Free Research Support Lecture 2: “Why? Zoo to find out “Why? ~Animals 2025

2025/7/4
0

2025】Okura Beach and Hayashizaki Beach will open on July 19 and July 5, respectively.

2025/7/4
0
第27回参議院議員通常選挙は7月20日投開票!期日前投票は7月4日

The 27th Ordinary Election for the House of Councillors will be held on July 20! Advance Voting is on July 4

2025/7/4
0

The 4th Summer Holiday Children’s Festival

2025/7/3
0
夏休み自由研究応援講座②「『なぜ?』を見つける動物園!~動物

Summer Holiday Free Research Support Lecture 2: “Why? Zoo to find out “Why? ~Animals

2025/7/2
0
オンラインショップ|オーダーメイド
beKOUE

  • Connecting
  • KOBE
  • Akashi
  • Technology
  • MeINPartner
  • GooallPartner
  • shAopEC Site
  • GlobalFactory
  • Booking
  • Community
  • Contact
  • Privacy Policy

Copyright 2025 by be Co., Ltd.

No Result
View All Result
  • 日本語
  • 中文 (中国)
  • Español
  • Connecting
  • KOBE
  • Akashi
  • Technology
  • Login
  • Sign Up
  • Community
  • Contact
  • Privacy Policy

Copyright 2025 by be Co., Ltd.

Welcome Back!

Sign In with Facebook
Sign In with Google
Sign In with Linked In
OR

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Sign Up with Facebook
Sign Up with Google
Sign Up with Linked In
OR

Fill the forms below to register

*By registering on this site, you can use the Terms of Service andPrivacy PolicyYou are deemed to have agreed.
All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Our site uses cookies. By continuing to use, we assume that you agree to our use of cookies. See Cookie Policy.
error: Alert: コンテンツは保護されています !!!