drxzpo70788179614
2018-04-20 22:58
浏览 61
已采纳

将图像添加到Woocommerce的管理顺序列表中的自定义操作按钮

Is there any way to get the img src in Woocommerce admin order list: That is the code of my PDF button, I just want to get the src image, I have two buttons 'Invoice' and 'Packing Slip', I want every button to get an image

// Add custom action buttons in woocommerce order list
add_filter( 'woocommerce_admin_order_actions', 'add_custom_print_actions_buttons', 100, 2 );
function add_custom_print_actions_buttons( $actions, $order ) {
    $opts = get_option('xc_woo_cloud_print_options', array());

    //if (isset($opts['printer']) && $opts['printer'] != "") {
        $domain = 'woocommerce-pdf-invoices-packing-slips';

        $slugs_label_names = array(
            'invoice'       => __('Invoice', $domain ),
            'packing-slip'  => __('Packing Slip', $domain )
        );

        // Set the action button
        foreach ( $slugs_label_names as $slug => $label_name ) {
            $actions[$slug] = array(
                'url'       => wp_nonce_url( admin_url( "admin-ajax.php?action=xc_woo_printer_job&document_type={$slug}&order_id=" . $order->get_id()), 'xc_woo_printer_job'),
                'alt' => esc_attr("Print " . $label_name),
                'title' => "Print " . $label_name
                'img' =>

            );
        }
    //}
 $actions = apply_filters('xc_woo_printer_meta_box_actions', $actions, $post_id);

    foreach ($actions as $document_type => $data) {
            ?>
            <a href="<?php echo $data['url']; ?>" class="button tips xc_ajax_button <?php echo $document_type; ?>" target="_blank" alt="<?php echo $data['alt']; ?>" data-tip="<?php echo $data['alt']; ?>">
                    <img src="<?php echo $data['img']; ?>" alt="<?php echo $data['alt']; ?>" width="16">
            </a>
            <?php
        }
}

图片转代码服务由CSDN问答提供 功能建议

有没有办法在Woocommerce管理订单列表中获取img src: 这是我的PDF按钮的代码 ,我只想获得src图像,我有两个按钮'Invoice'和'Packing Slip',我希望每个按钮都能获得一个图像</ p>

  //添加自定义动作 woocommerce订单列表中的按钮
add_filter('woocommerce_admin_order_actions','add_custom_print_actions_buttons',100,2); 
 
函数add_custom_print_actions_buttons($ actions,$ order){
 $ opts = get_option('xc_woo_cloud_print_options',array()); 
  
 // if(isset($ opts ['printer'])&amp;&amp; $ opts ['printer']!=“”){
 $ domain ='woocommerce-pdf-invoices-packing-slip';  
 
 $ slugs_label_names = array(
'invoice'=&gt; __('Invoice',$ domain),
'packing-slip'=&gt; __('Packing Slip',$ domain)
)  ; 
 
 //设置操作按钮
 foreach($ slugs_label_names as $ slug =&gt; $ label_name){
 $  actions [$ slug] = array(
'url'=&gt;  wp_nonce_url(admin_url(“admin-ajax.php?action = xc_woo_printer_job&amp; document_type = {$ slug}&amp; order_id =”。$ order-&gt; get_id()),'xc_woo_printer_job'),
'alt'=&gt;  esc_attr(“Print”。$ label_name),
'title'=&gt;  “打印”。  $ label_name 
'img'=&gt; 
 
); 
} 
 //} 
 $ actions = apply_filters('xc_woo_printer_meta_box_actions',$ actions,$ post_id); 
 
 foreach($ actions)  as $ document_type =&gt; $ data){
?&gt; 
&lt; a href =“&lt;?php echo $ data ['url'];?&gt;”  class =“按钮提示xc_ajax_button&lt;?php echo $ document_type;?&gt;”  target =“_ blank”alt =“&lt;?php echo $ data ['alt'];?&gt;”  data-tip =“&lt;?php echo $ data ['alt'];?&gt;”&gt; 
&lt; img src =“&lt;?php echo $ data ['img'];?&gt;”  alt =“&lt;?php echo $ data ['alt'];?&gt;”  width =“16”&gt; 
&lt; / a&gt; 
&lt;?php 
} 
} 
 </ code> </ pre> 
 </ div>

1条回答 默认 最新

相关推荐 更多相似问题