• Hi,

    I have created three custom dropdown fields to show in the front-end if it’s possbile make orders via email, phone and store. The cuestion is how can I show the value of the field in the front end?

    I have used the following code:

          $listing_template .= "\t\t\t" . '<% if ( retail_store ) { %>' . "\r\n";
          $listing_template .= "\t\t\t" . '<p>Retail Store Orders?: ' . __( 'Yes', 'wpsl' ) . '</p>' . "\r\n";
          $listing_template .= "\t\t\t" . '<% } %>' . "\r\n";

    But it doesn’t work.. also I haven’t found anything in the documentation how to show the value of dropdown custom fields https://wpstorelocator.co/document/wpsl_meta_box_fields/

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter andresgl

    (@andresgl)

    I solved my problem using the the field type “checkbox” although it will be nice if there is a solution if someone want to use the field type “dropdown”.

    Creating a new tab with the custom fields with the filter “wpsl_meta_box_fields” https://wpstorelocator.co/document/add-custom-meta-data-to-store-locations/:

    add_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields' );
    function custom_meta_box_fields( $meta_fields ) {
      $meta_fields[__( 'Additional Stockist Information', 'wpsl' )] = array(
          'retail_store_orders' => array(
            'label' => __( 'Retail Store Orders?', 'wpsl' ),
            'type'  => 'checkbox',
          ),
    
          'website_orders' => array(
            'label' => __( 'Website Orders?', 'wpsl' ),
            'type'  => 'checkbox',
    
          ),
    
          'email_orders' => array(
            'label' => __( 'Email Orders?', 'wpsl' ),
            'type'  => 'checkbox',
          ),
      );
      return $meta_fields;
    }

    Including additional meta data in the JSON response on the front end with the filter “wpsl_frontend_meta_fields” https://wpstorelocator.co/document/wpsl_frontend_meta_fields/

    add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );
    function custom_frontend_meta_fields( $store_fields ) {
      $store_fields['wpsl_retail_store_orders'] = array(
        'name' => 'retail_store_orders',
        'type' => 'checkbox'
      );
      $store_fields['wpsl_website_orders'] = array(
        'name' => 'website_orders',
        'type' => 'checkbox'
      );
      $store_fields['wpsl_email_orders'] = array(
        'name' => 'email_orders',
        'type' => 'checkbox'
      );
      return $store_fields;
    }

    Creating a custom template with the filter wpsl_listing_template to show the custom fields https://wpstorelocator.co/?s=wpsl_listing_template&post_type=wpsl_doc

        /////
        // Showing Custom option to order via website, Local store or phone
        ////
          $listing_template .= "\t\t" . '<div class="order-via">' . "\r\n";
          // retail store order
          $listing_template .= "\t\t\t" . '<% if ( retail_store_orders ) { %>' . "\r\n";
          $listing_template .= "\t\t\t" . '<p class="retail_store">' . __( '<span>Retail Store</span>', 'wpsl' ) . '</p>' . "\r\n";
          $listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
          // website order
          $listing_template .= "\t\t\t" . '<% if ( website_orders ) { %>' . "\r\n";
          $listing_template .= "\t\t\t" . '<p class="website">' . __( '<span>Website</span>', 'wpsl' ) . '</p>' . "\r\n";
          $listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
          // phoe order
          $listing_template .= "\t\t\t" . '<% if ( email_orders ) { %>' . "\r\n";
          $listing_template .= "\t\t\t" . '<p class="mail_order">' . __( '<span>Mail Order</span>', 'wpsl' ) . '</p>' . "\r\n";
          $listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
    
          $listing_template .= "\t\t" . '</div>' . "\r\n";
        /////
        // END Showing Custom option to order via website, Local store or phone
        ////
    • This reply was modified 7 years, 11 months ago by andresgl.
    Plugin Author Tijmen Smit

    (@tijmensmit)

    Just to be sure I understand the problem. You created a dropdown in the admin area to set if it’s possible to order by phone, email or in the store. And you want to show this single value in the search results for each location, or do you want to create an extra filter ( dropdown ) in the search block where the user can fill in the location they want to search in?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Display dropdown option in the custom listing template’ is closed to new replies.