Jump to content


Photo

Wordpress Widget modification: Pulling my hair out


  • Please log in to reply
7 replies to this topic

#1 Namika88

Namika88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 12 January 2018 - 08:09 PM

Hi all, i wonder if you can help me.
 
Basically, from the code that im pasting in here, i want to add a separate 'pickup' list, as at the moment it shows the destination list in both the pickup and destination location.
 
If anyone could please help it would be greatly appreciated.
 
Thanks in advance.
Adrian
 
 
        $select_destination_options = '<option value="">' . esc_html__('Select pickup location', 'transfers') . '</option>';
        $select_destination_options .= Transfers_Plugin_Utils::build_destination_select_recursively(null, $destination1_from_id);
        $select_pickup_location1 = '<select id="pickup1" name="p1">' . $select_destination_options . '</select>';
 
        $select_destination_options = '<option value="">' . esc_html__('Select drop-off location', 'transfers') . '</option>';
        $select_destination_options .= Transfers_Plugin_Utils::build_destination_select_recursively(null, $destination1_to_id, 0, false);
        $select_drop_off_location1 = '<select id="dropoff1" name="d1">' . $select_destination_options . '</select>';
 
        $select_destination_options = '<option value="">' . esc_html__('Select pickup location', 'transfers') . '</option>';
        $select_destination_options .= Transfers_Plugin_Utils::build_destination_select_recursively(null, $destination2_from_id);
        $select_pickup_location2 = '<select' . ($trip != 2 ? " disabled" : "") . ' id="pickup2" name="p2">' . $select_destination_options . '</select>';
 
        $select_destination_options = '<option value="">' . esc_html__('Select drop-off location', 'transfers') . '</option>';
        $select_destination_options .= Transfers_Plugin_Utils::build_destination_select_recursively(null, $destination2_to_id, 0, false);
        $select_drop_off_location2 = '<select' . ($trip != 2 ? " disabled" : "") . ' id="dropoff2" name="d2">' . $select_destination_options . '</select>';


#2 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,648 posts
  • LocationLos Angeles, CA USA

Posted 12 January 2018 - 09:31 PM

A good start would be to provide information about what App you are using here, and if there is a specific plugin or plugins to that App this code involves, you should explain that as well.

#3 Namika88

Namika88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 12 January 2018 - 11:11 PM

This is for an advanced search tool, i have attached the files that are required (i think) for the search to work, this is a widget done in php. Basically, you select a destination and a pickup point for the relevant day, select how many people are going and search. At the moment both the destination list and pickup list appear in the same sections.

see

http://lc.compton-computers.co.uk

and the 'widget' i am talking about you should beable to identify. Upon asking the author for help, they told me that i would need to edit lines 124 to 138 in the file widget-advanced-search.php which is attached.

Attached Files



#4 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,648 posts
  • LocationLos Angeles, CA USA

Posted 15 January 2018 - 07:16 PM

Where is the code for Transfers_Plugin_Utils?

#5 Namika88

Namika88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 16 January 2018 - 10:15 AM

this one? this was in the transfers folder.

Attached Files



#6 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,648 posts
  • LocationLos Angeles, CA USA

Posted 17 January 2018 - 02:18 AM

In that class the method Transfers_Plugin_Utils::build_destination_select_recursively that builds the list, there is this call:

$transfers_destination = new transfers_destination($destination_id);
Whatever this transfers_destination class does is what drives the building of the select list. Obviously there is database code in that class that is important to understand if you want to get a different list.

Candidly, I have had to intuit a lot of this information by looking at your site, rather than you providing the details needed in your question. You would need to explicitly describe what different information needs to be in the pickup list.

#7 Namika88

Namika88
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 17 January 2018 - 09:48 AM

Hi gizmola,

 

Thanks for getting back to me.

That is probably why i could not find where or what to edit as suggested by the author.

Basically i want 2 separate lists, one with the pickup locations and one with the destinations. At the moment the list that is used shows both pickup locations and destinations in one list.

I dont want the destinations to be visible in the pickup locations and dont want the pickup locations to be visible in the destinations list.

If necessary i'll email you the entire theme as i dont know what else i can supply you with.



#8 gizmola

gizmola
  • Administrators
  • Advanced Member
  • 4,648 posts
  • LocationLos Angeles, CA USA

Posted 17 January 2018 - 06:16 PM

I get the idea, and clearly what drives the list is the parameter that is passed to
 
$select_destination_options .= Transfers_Plugin_Utils::build_destination_select_recursively(null, $destination1_from_id);
$destination1_from_id is a parameter that then drives what the build_destination_select_recursively method does.


I went into that for you and provided the line above, where the data gets returned through a class:

transfers_destination($destination_id);
Typically there will be a class named transfers_destination, and the best practice is to put a class into its own file. So you should be looking for transfers_destination.php.

I'm going to assume that this package also came with at least one database table, or perhaps a few that are loaded with the data used to populate the lists. You need to understand how the database is being queried in order to understand what the ID is that would be required to make what you want happen.

With that said, I'm going to assume that if you have the right database information, all you really need is a different id variable/# to be passed to each dropdown.

You also really need to try and understand what is going on, and fix some of this yourself. It seems to me that at this point you could have paid someone for an hour of their time and had this working, and if you aren't really able to follow along, we are fast approaching the point where your problem has no particular value to the world at large.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users