Shipping Labels

Open to all! Ask other shopowners for help.
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Shipping Labels

Post by Kofod95 »

$GLOBALS['Admin']->link('orders.php', ['action' => 'labels'])

Looking at that, you might find some clues.
If you need the button per order (in the infoBox), you should probably use the hook to add to the infoBox.
I don't remember exactly how, but maybe something like;

Code: Select all

 listen_infoBox($parameters){
  $parameters['contents][] = ['text' => button-from-Burts-hook];
}
I usually find an add-on that does something similar to what I want, and use that as a starting point.

//Daniel


Join The Code Co-op to get access to your library in the Code Co-op Forum
AsTecModels
Member
Posts: 99
Joined: Wed Mar 18, 2026 6:20 pm
Phoenix Version: v1.1.0.6
Has thanked: 6 times
Been thanked: 3 times

Re: Shipping Labels

Post by AsTecModels »

I am almost there with the following code, apart from passing oID it is passing zero.

Code: Select all

<?php
class hook_admin_orders_labelMod {

  public function listen_extraButtons() {
    if (empty($_GET['action'])) {
      return $GLOBALS['Admin']->button('Label', 'fas fa-note-sticky', 'btn-info me-2', $GLOBALS['Admin']->link('envelope.php', 'oID=' . (int)$_GET['oID']));
    }
  }
  
}
Can someone tell me where i am going wrong and how to move button?
AsTecModels
Member
Posts: 99
Joined: Wed Mar 18, 2026 6:20 pm
Phoenix Version: v1.1.0.6
Has thanked: 6 times
Been thanked: 3 times

Re: Shipping Labels

Post by AsTecModels »

That bit works even though in wrong place, just can not get address to appear.

I am using a modified version of packingslip.php as that seems to have everything I need. I just can not get the address to appear. Is the error in the hook I have shown or would it be in the page I have created (envelope.php) ?
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Shipping Labels

Post by Kofod95 »

AsTecModels wrote: Thu Mar 26, 2026 11:35 pm Can someone tell me where i am going wrong and how to move button?
-When using $_GET['oID'] nothing is returned, if you don't have "'oID=XYZ" in the URL. You could fetch it from the object, rather than from the URL.
-Does your URL, when the button is clicked, look like: "/envelope.php?oID=0"? - if there's no "oID" in the URL, you might want to adjust your link-function.
-I have already answered how to move the button - at least mostly, you would need to adjust the array, to move your button to the top of the infoBox.
AsTecModels wrote: Thu Mar 26, 2026 11:53 pm Is the error in the hook I have shown or would it be in the page I have created (envelope.php) ?
If you manually type in a known order_id on envelope.php (fx "/envelope.php?oID=3") - does it then work? If so, all you need is to make your hook pass the order_id in the URL (see above). If not, you have a problem in envelope.php

//Daniel
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Shipping Labels

Post by burt »

If you need the button in the side box, that is a different Hook listener - listen_infoBox($parameters) as Daniel says in posting above.

You can try this;

Code: Select all

class hook_admin_orders_labelMod {

 public function listen_infoBox($parameters) {
    global $table_definition;

    $oid = (int)$GLOBALS['table_definition']['info']->orders_id;

    $parameters['contents'][] = ['class' => 'text-center', 'text' => $GLOBALS['Admin']->button('Label', 'fas fa-note-sticky', 'btn-info', $GLOBALS['Admin']->link('envelope.php', ['oID' => $oid]))];
  }

}
I am not here to build for you.
I am here to build with you. Let's help each other.
AsTecModels
Member
Posts: 99
Joined: Wed Mar 18, 2026 6:20 pm
Phoenix Version: v1.1.0.6
Has thanked: 6 times
Been thanked: 3 times

Re: Shipping Labels

Post by AsTecModels »

@burt That has put the button where I want.
@Kofod95 I was trying to get the right term, to place it correctly. Also yes I have the url look like: "/envelope.php?oID=0"
I must have an issue in my envelope.php from what you say :) Back to the drawing board unless someone wants to have a look and point me in right direction?? lol
User avatar
burt
Core Team
Posts: 4546
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Shipping Labels

Post by burt »

You might post the code of your `envelope.php` here, inside `code` tags, the </> button when replying..
AsTecModels
Member
Posts: 99
Joined: Wed Mar 18, 2026 6:20 pm
Phoenix Version: v1.1.0.6
Has thanked: 6 times
Been thanked: 3 times

Re: Shipping Labels

Post by AsTecModels »

Here is the code so far.

Code: Select all

<?php
/*
  $Id$

  CE Phoenix, E-Commerce made Easy
  https://phoenixcart.org

  Copyright (c) 2021 Phoenix Cart

  Released under the GNU General Public License
*/


  require 'includes/application_top.php';
  

  $currencies = new currencies();

  $oID = Text::input($_GET['oID']);

  $order = new order($oID);
  $customer_data = new customer_data();
  $address = $customer_data->get_module('address');

  require 'includes/template_top.php';
?>

  <div class="row align-items-center">
    <div class="col">
      <div style="height:100px;width:450px"><?= $Admin->catalog_image('images/' . STORE_LOGO, ['alt' => STORE_NAME]) ?></div>
      <p class="fw-bold m-0 p-0"><?= STORE_ADDRESS ?></p>
    </div>
    
  </div>

  <hr>

  <div class="row">
    <div class="col">
      <ul class="list-group border h-100">
      </ul>
    </div>
    <div class="col">
      <ul class="list-group border h-100">
        <li class="list-group-item border-0"><h6 class="lead m-0"><?= ENTRY_SHIP_TO ?></h6></li>
        <li class="list-group-item border-0 fw-bold"><?= $address->format($order->delivery, 1, '', '<br>') ?></li>
     </ul>
    </div>
    <div class="col">
      <ul class="list-group border h-100">
      </ul>
    </div>
  </div>


  <?= $admin_hooks->cat('extraComments') ?>

<?php
  require 'includes/template_bottom.php';
  require 'includes/application_bottom.php';
?>
AsTecModels
Member
Posts: 99
Joined: Wed Mar 18, 2026 6:20 pm
Phoenix Version: v1.1.0.6
Has thanked: 6 times
Been thanked: 3 times

Re: Shipping Labels

Post by AsTecModels »

I sussed and happy to set up as an Addon if anyone wants it.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply