I am trying to read values of 3 custom fields (colabs_price_basic, colabs_price_standard, colabs_price_premium) and one default field (colabs_price) into a dropdown list and select only one value at a time for form submission. The one value to be selected (service price package) is to be used for payment gateway checkout (paypal, bank transfer and paystack).

Although I have been able to read above mentioned custom fields from the database as can be seen in the screenshot attached, I am still not able to read it into my dropdown list (..... ... ) and use same for mathematical computation and then payment checkout. [enter image description here][1]

Var_dump() is currently displaying all the four fields (3 custom fields and one default field) on my page and on the text area of the dropdown list box.

<?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?>

See my form and codes below and please tell me what I am not doing right here. I need to read the four fields (colabs_price, colabs_price_basic, colabs_price_standard, colabs_price_premium) into my dropdown list box and use their values to do mathematical computation before checking out for payment.

I need help please to fix this problem. I have been on it for over almost 2 weeks now without success. Not yet too advanced with programming in PHP.

<?php
  global $post; $wpdb;
  // show the payment method box if enabled
  if ( get_option('colabs_charge_ads') == 'true' ) {
     if ( get_option('colabs_price_scheme') == 'single' && (get_option('colabs_enable_paypal') == 'true'||get_option('colabs_enable_bank') == 'true') && get_option('colabs_ad_parent_posting') != 'false' ): ?>
      <div class="input-select">
        <label><?php _e('Select Service Package By','colabsthemes'); ?> <?php the_author(); ?>:<span title="required">*</span></label>
        <div class="service fee">
            <?php if ( have_posts() ) : ?>
            <?php while ( have_posts() ) : the_post(); ?>
            <?php $colabs_price = get_post_meta($post->ID, 'colabs_price', true); ?>
            <?php $colabs_price_basic = get_post_meta($post->ID, 'colabs_price_basic', true); ?>
            <?php $colabs_price_standard = get_post_meta($post->ID, 'colabs_price_standard', true); ?>
            <?php $colabs_price_premium = get_post_meta($post->ID, 'colabs_price_premium', true); ?>
            <select name="service_pack" class="dropdownlist required">
               <option selected="selected">Choose Service Package</option>
                    <option value="<?php if ( empty($colabs_price) ) echo colabs_get_price_legacy($post->ID); else echo colabs_get_price($post->ID, 'colabs_price'); ?>"><?php if ( empty($colabs_price) ) colabs_get_price_legacy($post->ID); else colabs_get_price($post->ID, 'colabs_price'); ?>-One-off Price</option>
                    <option value="<?php if ( empty($colabs_price_basic) ) echo colabs_get_price_legacy($post->ID); else echo colabs_get_price($post->ID, 'colabs_price_basic'); ?>"><?php if ( empty($colabs_price_basic) ) colabs_get_price_legacy($post->ID); else colabs_get_price($post->ID, 'colabs_price_basic'); ?>-Basic Price</option>
                    <option value="<?php if ( empty($colabs_price_standard) ) echo colabs_get_price_legacy($post->ID); else echo colabs_get_price($post->ID, 'colabs_price_standard'); ?>"><?php if ( empty($colabs_price_standard) ) colabs_get_price_legacy($post->ID); else colabs_get_price($post->ID, 'colabs_price_standard'); ?>-Standard Price</option>
                    <option value="<?php if ( empty($colabs_price_premium) ) echo colabs_get_price_legacy($post->ID); else echo colabs_get_price($post->ID, 'colabs_price_premium'); ?>"><?php if ( empty($colabs_price_premium) ) colabs_get_price_legacy($post->ID); else colabs_get_price($post->ID, 'colabs_price_premium'); ?>-Premium Price</option
            </select>
            <?php endwhile; ?>
            <?php else: ?>
                <?php _e('Error: no ad pack has been defined. Please contact the site administrator.', 'colabsthemes') ?>
            <?php endif; wp_reset_postdata(); ?>

        </div><!-- /.ad-categories -->
      </div>
    <?php endif;
    if ( get_option('colabs_enable_coupons') == 'true' ) : ?>
      <div class="input-text">
          <label><?php _e('Enter Coupon Code','colabsthemes'); ?>:</label>
          <input type="text" class="text" value="" id="colabs_coupon_code" name="colabs_coupon_code">
      </div>
  <?php endif;
  } // end charge for ads check
  ?>
          <div id="ad-form-input" class="input-submit">
            <input style="display:block" type="submit" name="order1" id="order1" class="btn btn-primary" value="<?php _e('Continue','colabsthemes'); ?>" />
            <div id="chosenorder"><input id="order" name="result" type="input" value="<?php echo ($_POST[$colabs_price] || $_POST[$colabs_price_basic] || $_POST[$colabs_price_standard] || $_POST[$colabs_price_premium]); ?>" /></div>
          </div>

        <!-- /.col6 -->

        <input type="hidden" id="fid" name="fid" value="<?php if(isset($_POST['fid'])) echo $_POST['fid']; ?>" />
        <input type="hidden" id="oid" name="oid" value="<?php echo $order_id; ?>" />
</form>

</div>
</div>
</div>````

Awaiting feedbacks.


  [1]: https://i.stack.imgur.com/G3HqX.png

0 Answers