Support » Plugin: Easy Upload Files During Checkout » easy_ufdc_box_order_detail problem

  • Resolved infocon

    (@infocon)


    Hi, There is a problem in the function.php file. When the object supplied to the function is an order, the line
    $ order = new WC_Order ($ post-> ID);
    goes wrong.
    You should replace the code from line 591.

    if(!function_exists(‘easy_ufdc_box_order_detail’)){
    function easy_ufdc_box_order_detail($post) {

    $ret = ”;
    $upload_count_outer = 0;
    if(is_numeric($post)):
    $my_id = $post;
    $order = new WC_Order($post);
    else:
    if($post instanceof WP_Post):
    $order = new WC_Order($post->ID);
    $my_id = $order->get_id();
    else:
    $order = $post;
    $my_id = $order->get_id();
    endif;
    endif;
    //pre(get_post_meta( $post->ID));

    $j=1;
    /* per product een formulier met gegevens */
    foreach ( $order->get_items() as $order_item ) {
    $max_upload_count=1;
    //$max_upload_count=get_max_upload_count_plus($order,$order_item[‘product_id’]);

    $forproduct = $order_item[‘name’];
    $ret .= ‘‘;
    $ret .= sprintf( __(‘File for product’,’easy-upload-files-during-checkout’).’: “%s”‘, $forproduct);
    $ret .= ‘
    <br>’;

    /* Controle of er al een bestand is geupload */

    $i=1;
    $upload_count=0;
    $ret .= ‘

      ‘;
      while ($i <= $max_upload_count) {
      $ret .= ‘

    • ‘;
      $name = get_post_meta( $my_id, ‘_woo_ufdc_uploaded_file_name_’ . $j, true );
      $uploaded_file_path = get_post_meta( $my_id, ‘_woo_ufdc_uploaded_file_path_’ . $j, true );
      //pre($uploaded_file_path);

      $uploaded_file_path = str_replace(array(‘http:’, ‘https:’), ”, $uploaded_file_path);
      $url = str_replace( ABSPATH, home_url(‘/’), $uploaded_file_path);
      $url = (strpos($url, home_url(‘/’))?$url:home_url(‘/’).$url);

      $forproduct = get_post_meta( $my_id, ‘_woo_ufdc_uploaded_product_name_’ . $j, true );
      if( !empty( $url ) && !empty( $name ) ) {
      $url = eufdc_secure_download_link($my_id, $j, $url);
      $ret .= sprintf( ‘%s‘, $url, $name );
      $upload_count++;
      $upload_count_outer++;
      } else {
      //silence is golden
      }
      $i++;
      $j++;
      $ret .= ‘

    • ‘;
      }
      $ret .= ‘

    ‘;
    //}
    }

    echo ($upload_count_outer?$ret:”);
    }
    }

    thanks for this very useful plugin.
    Greetings
    Stefano

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Fahad Mahmood

    (@fahadmahmood)

    Releasing a new version with these improvements, please try 1.7.1 and give your feedback.

    Tried 1.7.1

    There is
    Undefined index: HTTP_REFERER in wp-content/plugins/easy-upload-files-during-checkout/inc/functions.php on line 307

    I think this in line 306

    if(isset($_SERVER[‘HTTP_REFERER’])) {
    $same_page = (stristr($_SERVER[‘HTTP_REFERER’], $_SERVER[‘REQUEST_URI’]));
    }
    else
    {
    $same_page = “”;
    }

    thanks to you.
    Greetings
    Stefano

    Plugin Author Fahad Mahmood

    (@fahadmahmood)

    Stefano,

    You are doing great contributions, i like it. Please see development tab for changelog with your name against version numbers. In this snippet, same_page=false will work better in else case. Please try v.1.7.2.

    Thanks,
    Fahad

    Hi Fahad, thanks for changelog with my name.
    Now the plugin works perfectly. In this case it is installed with the latest version of wordpress and woocommerce.
    Greetings
    Stefano

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.