• Iam using eShop Free wordpress plugin.. (eveyrthing is fine with this plugin..)

    BUT I need some customizations as per my requirement.. At first I need to add some extra fields

    Iam thinking to have one small form in which it contains details like keywords, url etc.. between cart and checkout somewhere, so that my visitor enter those details and so I can get his order details along with payment..

    So for that, they provided this: https://quirm.net/wiki/eshop/additional-plugins-and-code-snippets/add-a-field-to-the-checkout/

    BUT I have another problem..

    Actually I need different fields for each page of same site..

    (say for Page1 Service, i need field1, field2)
    (say for Page2 Service, i need field3, field4)
    (say for Page3 Service, i need field5, field6)

    So to achieve above, what I have to do..?

    FYI, here is the code of eshop-extras.php
    ———————————————-

    // Make additional checkout field mandatory
    add_filter(‘eshopCheckoutReqd’,’eshop_extras_required’);
    function eshop_extras_required($values) {
    $values[] = ‘eshop_extra’;
    return $values;
    }

    // Add an additional field to the checkout within a new fieldset
    add_filter(‘eshopaddtocheckout’,’eshop_extras_checkout’);
    function eshop_extras_checkout($echo){
    $echo .= ‘<fieldset class=”eshop eshop_extra”>’ . “\n”;
    $echo .= ‘<legend>Extras</legend>’ . “\n”;
    $echo .= ‘<label for=”eshop_extra”>’.__(‘Extra Field’,’eshop’).’ <span class=”reqd”>*</span>
    <input class=”short” type=”text” name=”eshop_extra” value=”” id=”eshop_extra” maxlength=”20″ size=”20″ /></label>’;

    $echo .= ‘<label for=”keywords”>’.__(‘Keywords’,’eshop’).’ <span class=”reqd”>*</span>
    <input class=”short” type=”text” name=”keywords” value=”” id=”keywords” maxlength=”20″ size=”20″ /></label>’;

    $echo .= ‘</fieldset>’ . “\n”;
    return $echo;
    }

    // Add extra field to error checks
    add_filter(‘eshoperrorcheckout’,’eshop_extras_errorcheckout’);
    function eshop_extras_errorcheckout($_POST){
    $myerror=”;
    if(!isset($_POST[‘eshop_extra’]) || trim($_POST[‘eshop_extra’])==”){
    $myerror= ‘

    • ‘.__(‘Extra Field – missing.’,’eshop_extras’).’
    • ‘;
      }
      return $myerror;
      }

      // Adds extra field to confirm details
      add_filter(‘eshopconfcheckout’,’eshop_extras_confcheckout’);
      function eshop_extras_confcheckout($_POST){
      $echoit=”;
      if( isset($_POST[‘eshop_extra’]) && $_POST[‘eshop_extra’] !=” ) {
      $echoit.='<h4>’.__(‘Extras’,’eshop’).'</h4><ul class=”eshop confirm”>’;
      $echoit.= “

    • <span class=\”items\”>”.__(‘Extra Field:’,’eshop’).”</span> “.$_POST[‘eshop_extra’].”

    \n”;
    }
    return $echoit;
    }

    // Saves extra field data in db
    add_action(‘eshoporderhandle’,’eshop_extras_orderhandle’,1,2);
    function eshop_extras_orderhandle($_POST,$checkid){
    //we need to save the data
    global $wpdb;
    if(isset($_POST[‘eshop_extra’]) && $_POST[‘eshop_extra’]!=”){
    $table = $wpdb->prefix . “eshop_orders”;
    $eshop_extra=$wpdb->escape($_POST[‘eshop_extra’]);
    $query1=$wpdb->query(“UPDATE $table SET eshop_extra=’$eshop_extra’ where checkid=’$checkid’ limit 1”);
    }
    }

    // Adds extra field to details display
    add_action(‘eshopshowuserdetails’,’eshop_extras_showdetails’,1,1);
    add_action(‘eshopshowdetails’,’eshop_extras_showdetails’,1,1);
    function eshop_extras_showdetails($row){
    //add to order details page
    if($row->eshop_extra!=”){
    echo ‘<hr class=”eshopclear” />’;
    echo ‘<div><h4>Extra Field</h4>’;
    echo $row->eshop_extra.'</div>’;
    }
    }

    // Adds extra field to data extraction routines
    add_filter(‘eshoprtndetails’,’eshop_extras_rtndetails’);
    function eshop_extras_rtndetails($dquery){
    //extracting data from db for use whereever
    foreach($dquery as $drow){
    $eshop_extra=$drow->eshop_extra;
    }
    $array[‘eshop_extra’]=”Extra Field\n”.$eshop_extra.”\n”;
    return $array;
    }

    // Adds extra field to emails
    add_action(‘eshopemailtags’,’eshop_extras_emailtags’);
    function eshop_extras_emailtags(){
    // display any new codes
    ?>

    • {EXTRA} – <?php _e(‘Extra Fields.’,’eshop’); ?>
    • <?php
      }

      add_filter(‘eshopemailparse’,’eshop_extras_emailparse’);
      function eshop_extras_emailparse($filterit){
      $array=$filterit[0];
      $this_email=$filterit[1];
      $this_email = str_replace(‘{EXTRA}’, $array[‘eshop_extra’], $this_email);
      return $this_email;
      }

      register_activation_hook(__FILE__,’eshop_extras_install’);
      function eshop_extras_install(){
      //add to db on install
      global $wpdb;
      $table = $wpdb->prefix . “eshop_orders”;
      $tablefields = $wpdb->get_results(“DESCRIBE {$table}”);
      $add_field = TRUE;
      foreach ($tablefields as $tablefield) {
      if(strtolower($tablefield->Field)==’eshop_extra’) {
      $add_field = FALSE;
      }
      }
      if ($add_field) {
      $sql=”ALTER TABLE ".$table." ADD eshop_extra TEXT NOT NULL”;
      $wpdb->query($sql);
      }
      }

      **Please suggest me how can i achive custom differnt fields between cart and checkout for each service page of same site?**

      Waiting for your responses!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Need Custom Different fields for each page between cart and checkout?’ is closed to new replies.