Adding a new adress-field in orders.php

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: Adding a new adress-field in orders.php

Post by Kofod95 »

I got it working, big thanks to @ecartz! (I don't know how to tag users)

Just for the eventual benefit of others:
  • I copied a customer data module (module and language files) which worked the way I wanted my new one to work, and renamed the files, class, constants, variables and off-sets
  • I made a new column in the database (In my case, in the address_book table, as I wanted my new info to follow the delivery-address)
  • I copied cd_traditional_address (module and language), renamed files, class and constants and copied line 92

    Code: Select all

          $company = htmlspecialchars($address['company'] ?? '');

    and inserted it where I wanted it, as well as modified it to suit my needs (renamed first variable and the off-set)
  • Next I added a new column in the database, on the orders table
  • Lastly I made a hook to insert the new field in my new column on the orders-table:

    Code: Select all

    class hook_shop_siteWide_insertPhone {
      
      function listen_insertOrder($parameters) {
    	  
    	$order =& $GLOBALS['order'];
    
    	$parameters['sql_data']['orders']['delivery_recievers_phone'] = $GLOBALS['customer_data']->get('recievers_phone', $order->delivery);
      }
      
    }
    
It works and I think it is a fine way to do things. My biggest concern is the database-changes, as I like to keep the structure as vanilla as possible, and prefer adding new tables over adjusting existing onces. I don't have any reason for this, so I'm propably just weird!

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


Join The Code Co-op to get access to your library in the Code Co-op Forum
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Adding a new adress-field in orders.php

Post by heatherbell »

@Kofod95
Glad you got it working - thanks for sharing.
To mention or tag a member you can type @ followed by a character and a drop-down of members should appear (some browsers have problems).
Or you can enter the tag like:

Code: Select all

[mention]@Kofod95[/mention]
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: Adding a new adress-field in orders.php

Post by Kofod95 »

@heatherbell
Thank you!
My browser (Google Chrome) don't offer the drop-down (neither on phone or PC), and 'mention' gives this
You cannot use certain BBCodes: mention].
I'll see if I have disabled something by accident :oops:

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Adding a new adress-field in orders.php

Post by heatherbell »

Kofod95 wrote: Mon Mar 22, 2021 9:37 am My browser (Google Chrome) don't offer the drop-down
It *might* be a browser cache issue so try clearing that - works on Chrome for me.
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Adding a new adress-field in orders.php

Post by ecartz »

heatherbell wrote: Mon Mar 22, 2021 9:57 am
Kofod95 wrote: Mon Mar 22, 2021 9:37 am My browser (Google Chrome) don't offer the drop-down
It *might* be a browser cache issue so try clearing that - works on Chrome for me.
I think it might be a permissions issue. I note that the @heatherbell account is a member of groups that Kofod95 is not. That message is certainly the kind of thing that would show with a permissions issue. Now, where ACP might hide the permissions for using mentions is something that I don't know. Under the group? Under some section about mentions?
admin
Contributor
Posts: 217
Joined: Wed Oct 30, 2019 1:34 pm
Phoenix Version:
Has thanked: 20 times
Been thanked: 22 times

Re: Adding a new adress-field in orders.php

Post by admin »

ecartz wrote: Mon Mar 22, 2021 11:08 am I think it might be a permissions issue.
Yes, I think it is too - @Kofod95 try again?
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: Adding a new adress-field in orders.php

Post by Kofod95 »

@heatherbell, @admin and @ecartz

Even the drop-down works now! Thank you! :)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


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