<i id='mzIbx'><tr id='mzIbx'><dt id='mzIbx'><q id='mzIbx'><span id='mzIbx'><b id='mzIbx'><form id='mzIbx'><ins id='mzIbx'></ins><ul id='mzIbx'></ul><sub id='mzIbx'></sub></form><legend id='mzIbx'></legend><bdo id='mzIbx'><pre id='mzIbx'><center id='mzIbx'></center></pre></bdo></b><th id='mzIbx'></th></span></q></dt></tr></i><div id='mzIbx'><tfoot id='mzIbx'></tfoot><dl id='mzIbx'><fieldset id='mzIbx'></fieldset></dl></div>
    <bdo id='mzIbx'></bdo><ul id='mzIbx'></ul>

    <tfoot id='mzIbx'></tfoot>

    <small id='mzIbx'></small><noframes id='mzIbx'>

      <legend id='mzIbx'><style id='mzIbx'><dir id='mzIbx'><q id='mzIbx'></q></dir></style></legend>
    1. 将操作按钮添加到在新窗口中打开的 Woocommerce 我的帐户订单

      Add an action button to Woocommerce my account orders that open in a new window(将操作按钮添加到在新窗口中打开的 Woocommerce 我的帐户订单)
    2. <legend id='FEpH3'><style id='FEpH3'><dir id='FEpH3'><q id='FEpH3'></q></dir></style></legend>

      <i id='FEpH3'><tr id='FEpH3'><dt id='FEpH3'><q id='FEpH3'><span id='FEpH3'><b id='FEpH3'><form id='FEpH3'><ins id='FEpH3'></ins><ul id='FEpH3'></ul><sub id='FEpH3'></sub></form><legend id='FEpH3'></legend><bdo id='FEpH3'><pre id='FEpH3'><center id='FEpH3'></center></pre></bdo></b><th id='FEpH3'></th></span></q></dt></tr></i><div id='FEpH3'><tfoot id='FEpH3'></tfoot><dl id='FEpH3'><fieldset id='FEpH3'></fieldset></dl></div>
      <tfoot id='FEpH3'></tfoot>
          <bdo id='FEpH3'></bdo><ul id='FEpH3'></ul>

                <tbody id='FEpH3'></tbody>

              <small id='FEpH3'></small><noframes id='FEpH3'>

              1. 本文介绍了将操作按钮添加到在新窗口中打开的 Woocommerce 我的帐户订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我将从我的帐户订单中添加一个按钮,使其转到特定的网址.我做了一个按钮,但我想用一个新窗口打开它而不是去页面.我该怎么办?下面是我添加的代码,我想在这里用笼子打开url:

                I'm going to add a button from my account order to make it go to a specific url. I made a button, but I want to open it with a new window instead of going to the page. What should I do? Down below is the code I added, and I'd like to open url here with a cage:

                function sv_add_my_account_order_actions( $actions, $order ) {
                
                    $actions['name'] = array(
                        'url'  => 'the_action_url',
                        'name' => 'The Button Text',
                    );
                    return $actions;
                }
                add_filter( 'woocommerce_my_account_my_orders_actions', 'sv_add_my_account_order_actions', 10, 2 );
                

                如何将 target="_blank" 添加到每个额外的自定义按钮?

                how to add target="_blank" to each additional custom button?

                推荐答案

                使用以下内容将向每个特定操作 html 标记添加属性 target_blank 值在新窗口中打开链接:

                Use the following that will add to each specific action html tag the attribute target with a _blank value opening the link in a new window:

                // Your additional action button
                add_filter( 'woocommerce_my_account_my_orders_actions', 'add_my_account_my_orders_custom_action', 10, 2 );
                function add_my_account_my_orders_custom_action( $actions, $order ) {
                    $action_slug = 'specific_name';
                
                    $actions[$action_slug] = array(
                        'url'  => home_url('/the_action_url/'),
                        'name' => 'The Button Text',
                    );
                    return $actions;
                }
                
                // Jquery script
                add_action( 'woocommerce_after_account_orders', 'action_after_account_orders_js');
                function action_after_account_orders_js() {
                    $action_slug = 'specific_name';
                    ?>
                    <script>
                    jQuery(function($){
                        $('a.<?php echo $action_slug; ?>').each( function(){
                            $(this).attr('target','_blank');
                        })
                    });
                    </script>
                    <?php
                }
                

                代码在您的活动子主题(或活动主题)的functions.php 文件中.经过测试并且可以工作.

                Code goes in functions.php file of your active child theme (or active theme). Tested and works.

                您必须在两个函数中设置相同的唯一且显式的 $action_slug 变量.

                You will have to set the same unique and explicit $action_slug variable in both functions.

                <小时>

                要仅定位完成的订单,请在第一个函数中添加 if ( $order->has_status('completed') ) { ,例如:


                To target orders complete only, add if ( $order->has_status('completed') ) { in the first function only like:

                add_filter( 'woocommerce_my_account_my_orders_actions', 'add_my_account_my_orders_custom_action', 10, 2 );
                function add_my_account_my_orders_custom_action( $actions, $order ) {
                    if ( $order->has_status( 'completed' ) ) {
                        $action_slug = 'specific_name';
                
                        $actions[$action_slug] = array(
                            'url'  => home_url('/the_action_url/'),
                        'name' => 'The Button Text',
                        );
                    }
                    return $actions;
                }
                

                这篇关于将操作按钮添加到在新窗口中打开的 Woocommerce 我的帐户订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <i id='d87RV'><tr id='d87RV'><dt id='d87RV'><q id='d87RV'><span id='d87RV'><b id='d87RV'><form id='d87RV'><ins id='d87RV'></ins><ul id='d87RV'></ul><sub id='d87RV'></sub></form><legend id='d87RV'></legend><bdo id='d87RV'><pre id='d87RV'><center id='d87RV'></center></pre></bdo></b><th id='d87RV'></th></span></q></dt></tr></i><div id='d87RV'><tfoot id='d87RV'></tfoot><dl id='d87RV'><fieldset id='d87RV'></fieldset></dl></div>

                      <legend id='d87RV'><style id='d87RV'><dir id='d87RV'><q id='d87RV'></q></dir></style></legend>
                    • <small id='d87RV'></small><noframes id='d87RV'>

                        <tbody id='d87RV'></tbody>
                        <bdo id='d87RV'></bdo><ul id='d87RV'></ul>
                          <tfoot id='d87RV'></tfoot>