Page 1 of 3 123 LastLast
Results 1 to 10 of 25
  1. #1
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Custom serial display help

    Ok so here is the deal, I made a nice little script that adds serial codes for each application we sell over zen cart, i tied it in with the products table and the product ID so the database relations are all there. Now the insertion and deletion of codes works through my script, but im a bit lost on which file do i show the code after a successful purchase, i have a query made that will get the serial based on the productID and weather its been viewed or not, on what file does it show the successful checkout and what variable determins the productID, maybe a session or a cookie?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Custom serial display help

    You could try something like I described here while trying to help someone with a similar question (but they want an entirely different approach apparently): http://www.zen-cart.com/forum/showthread.php?t=101901

    Similar discussions can be found by searching the forum for "serial"
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Re: Custom serial display help

    Hey thanks for the help, i made the function and am calling the function and query ok, but i cant seem to make it appear either in the email or on the order successful page, any help?

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Custom serial display help

    If you add it to the $this->products_ordered_attributes variable as shown in the code snippets I posted, it will be included on the order emails and in the My Account order history.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Re: Custom serial display help

    so add that in the create_add_products() function?

    and if so where in the function, at the very bottom?

  6. #6
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Custom serial display help

    Exactly in the place shown:
    Code:
    /* START: ADD MY CUSTOM DETAILS
     * 1. calculate/prepare custom information to be added to this product entry in order-confirmation.
     * 2. Add that data to the $this->products_ordered_attributes variable, using this sort of format:
     *      $this->products_ordered_attributes .=  {INSERT CUSTOM INFORMATION HERE};
     */
    
        $this->products_ordered_attributes .= ''; // $custom_insertable_text;
    
    /* END: ADD MY CUSTOM DETAILS */
    And the example I posted here is one way to do it:
    Quote Originally Posted by DrByte View Post
    Sample concept:
    replace this code from the section I quoted earlier:
    Code:
        $this->products_ordered_attributes .= ''; // $custom_insertable_text;
    with something like this:
    Code:
        $product_serial_number = my_custom_get_serialnumber_function($this->products[$i]['id'], $this->products[$i]['qty'], $zf_insert_id);
        $this->products_ordered_attributes .= $product_serial_number;
    And in your custom function treat the parameters as ProductID, Quantity, OrderNumber, and return a string value containing the serial number for the specified product.
    You could further enhance it by passing the specific attribute number as well if you needed to differentiate that further.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Re: Custom serial display help

    Ok i get that and im not trying to be a pain here but this is the current create_add_products function that i have

    PHP Code:
      function  create_add_products($zf_insert_id$zf_mode false) {
        global 
    $db$currencies$order_total_modules$order_totals$zco_notifier;

        
    // initialized for the email confirmation

        
    $this->products_ordered '';
        
    $this->products_ordered_html '';
        
    $this->subtotal 0;
        
    $this->total_tax 0;

        
    // lowstock email report
        
    $this->email_low_stock='';

        for (
    $i=0$n=sizeof($this->products); $i<$n$i++) {
          
    // Stock Update - Joao Correia
          
    if (STOCK_LIMITED == 'true') {
            if (
    DOWNLOAD_ENABLED == 'true') {
              
    $stock_query_raw "select p.products_quantity, pad.products_attributes_filename, p.product_is_always_free_shipping
                                  from " 
    TABLE_PRODUCTS " p
                                  left join " 
    TABLE_PRODUCTS_ATTRIBUTES " pa
                                   on p.products_id=pa.products_id
                                  left join " 
    TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD " pad
                                   on pa.products_attributes_id=pad.products_attributes_id
                                  WHERE p.products_id = '" 
    zen_get_prid($this->products[$i]['id']) . "'";

              
    // Will work with only one option for downloadable products
              // otherwise, we have to build the query dynamically with a loop
              
    $products_attributes $this->products[$i]['attributes'];
              if (
    is_array($products_attributes)) {
                
    $stock_query_raw .= " AND pa.options_id = '" $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" $products_attributes[0]['value_id'] . "'";
              }
              
    $stock_values $db->Execute($stock_query_raw);
            } else {
              
    $stock_values $db->Execute("select * from " TABLE_PRODUCTS " where products_id = '" zen_get_prid($this->products[$i]['id']) . "'");
            }

            
    $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_BEGIN');

            if (
    $stock_values->RecordCount() > 0) {
              
    // do not decrement quantities if products_attributes_filename exists
              
    if ((DOWNLOAD_ENABLED != 'true') || $stock_values->fields['product_is_always_free_shipping'] == || (!$stock_values->fields['products_attributes_filename']) ) {
                
    $stock_left $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
                
    $this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
              } else {
                
    $stock_left $stock_values->fields['products_quantity'];
              }

              
    //            $this->products[$i]['stock_value'] = $stock_values->fields['products_quantity'];

              
    $db->Execute("update " TABLE_PRODUCTS " set products_quantity = '" $stock_left "' where products_id = '" zen_get_prid($this->products[$i]['id']) . "'");
              
    //        if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
              
    if ($stock_left <= 0) {
                
    // only set status to off when not displaying sold out
                
    if (SHOW_PRODUCTS_SOLD_OUT == '0') {
                  
    $db->Execute("update " TABLE_PRODUCTS " set products_status = 0 where products_id = '" zen_get_prid($this->products[$i]['id']) . "'");
                }
              }

              
    // for low stock email
              
    if ( $stock_left <= STOCK_REORDER_LEVEL ) {
                
    // WebMakers.com Added: add to low stock email
                
    $this->email_low_stock .=  'ID# ' zen_get_prid($this->products[$i]['id']) . "\t\t" $this->products[$i]['model'] . "\t\t" $this->products[$i]['name'] . "\t\t" ' Qty Left: ' $stock_left "\n";
              }
            }
          }

          
    // Update products_ordered (for bestsellers list)
          //    $db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . zen_get_prid($order->products[$i]['id']) . "'");
          
    $db->Execute("update " TABLE_PRODUCTS " set products_ordered = products_ordered + " sprintf('%f'$this->products[$i]['qty']) . " where products_id = '" zen_get_prid($this->products[$i]['id']) . "'");

          
    $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END');

          
    $sql_data_array = array('orders_id' => $zf_insert_id,
                                  
    'products_id' => zen_get_prid($this->products[$i]['id']),
                                  
    'products_model' => $this->products[$i]['model'],
                                  
    'products_name' => $this->products[$i]['name'],
                                  
    'products_price' => $this->products[$i]['price'],
                                  
    'final_price' => $this->products[$i]['final_price'],
                                  
    'onetime_charges' => $this->products[$i]['onetime_charges'],
                                  
    'products_tax' => $this->products[$i]['tax'],
                                  
    'products_quantity' => $this->products[$i]['qty'],
                                  
    'products_priced_by_attribute' => $this->products[$i]['products_priced_by_attribute'],
                                  
    'product_is_free' => $this->products[$i]['product_is_free'],
                                  
    'products_discount_type' => $this->products[$i]['products_discount_type'],
                                  
    'products_discount_type_from' => $this->products[$i]['products_discount_type_from'],
                                  
    'products_prid' => $this->products[$i]['id']);
          
    zen_db_perform(TABLE_ORDERS_PRODUCTS$sql_data_array);

          
    $order_products_id $db->Insert_ID();

          
    $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_CREDIT_ACCOUNT_UPDATE_BEGIN');
          
    $order_total_modules->update_credit_account($i);//ICW ADDED FOR CREDIT CLASS SYSTEM

          
    $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_ATTRIBUTES_BEGIN');

          
    //------ bof: insert customer-chosen options to order--------
          
    $attributes_exist '0';
          
    $this->products_ordered_attributes '';
          if (isset(
    $this->products[$i]['attributes'])) {
            
    $attributes_exist '1';
            for (
    $j=0$n2=sizeof($this->products[$i]['attributes']); $j<$n2$j++) {
              if (
    DOWNLOAD_ENABLED == 'true') {
                
    $attributes_query "select popt.products_options_name, poval.products_options_values_name,
                                     pa.options_values_price, pa.price_prefix,
                                     pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix,
                                     pa.attributes_discounted, pa.attributes_price_base_included, pa.attributes_price_onetime,
                                     pa.attributes_price_factor, pa.attributes_price_factor_offset,
                                     pa.attributes_price_factor_onetime, pa.attributes_price_factor_onetime_offset,
                                     pa.attributes_qty_prices, pa.attributes_qty_prices_onetime,
                                     pa.attributes_price_words, pa.attributes_price_words_free,
                                     pa.attributes_price_letters, pa.attributes_price_letters_free,
                                     pad.products_attributes_maxdays, pad.products_attributes_maxcount, pad.products_attributes_filename,
                                     pa.product_attribute_is_free, pa.attributes_discounted
                                     from " 
    TABLE_PRODUCTS_OPTIONS " popt, " TABLE_PRODUCTS_OPTIONS_VALUES " poval, " .
                
    TABLE_PRODUCTS_ATTRIBUTES " pa
                                      left join " 
    TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD " pad
                                      on pa.products_attributes_id=pad.products_attributes_id
                                     where pa.products_id = '" 
    zen_db_input($this->products[$i]['id']) . "'
                                      and pa.options_id = '" 
    $this->products[$i]['attributes'][$j]['option_id'] . "'
                                      and pa.options_id = popt.products_options_id
                                      and pa.options_values_id = '" 
    $this->products[$i]['attributes'][$j]['value_id'] . "'
                                      and pa.options_values_id = poval.products_options_values_id
                                      and popt.language_id = '" 
    $_SESSION['languages_id'] . "'
                                      and poval.language_id = '" 
    $_SESSION['languages_id'] . "'";

                
    $attributes_values $db->Execute($attributes_query);
              } else {
                
    $attributes_values $db->Execute("select popt.products_options_name, poval.products_options_values_name,
                                     pa.options_values_price, pa.price_prefix,
                                     pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix,
                                     pa.attributes_discounted, pa.attributes_price_base_included, pa.attributes_price_onetime,
                                     pa.attributes_price_factor, pa.attributes_price_factor_offset,
                                     pa.attributes_price_factor_onetime, pa.attributes_price_factor_onetime_offset,
                                     pa.attributes_qty_prices, pa.attributes_qty_prices_onetime,
                                     pa.attributes_price_words, pa.attributes_price_words_free,
                                     pa.attributes_price_letters, pa.attributes_price_letters_free
                                     from " 
    TABLE_PRODUCTS_OPTIONS " popt, " TABLE_PRODUCTS_OPTIONS_VALUES " poval, " TABLE_PRODUCTS_ATTRIBUTES " pa
                                     where pa.products_id = '" 
    . (int)$this->products[$i]['id'] . "' and pa.options_id = '" . (int)$this->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$this->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" $_SESSION['languages_id'] . "' and poval.language_id = '" $_SESSION['languages_id'] . "'");
              }

              
    //clr 030714 update insert query.  changing to use values form $order->products for products_options_values.
              
    $sql_data_array = array('orders_id' => $zf_insert_id,
                                      
    'orders_products_id' => $order_products_id,
                                      
    'products_options' => $attributes_values->fields['products_options_name'],

              
    //                                 'products_options_values' => $attributes_values->fields['products_options_values_name'],
                                      
    'products_options_values' => $this->products[$i]['attributes'][$j]['value'],
                                      
    'options_values_price' => $attributes_values->fields['options_values_price'],
                                      
    'price_prefix' => $attributes_values->fields['price_prefix'],
                                      
    'product_attribute_is_free' => $attributes_values->fields['product_attribute_is_free'],
                                      
    'products_attributes_weight' => $attributes_values->fields['products_attributes_weight'],
                                      
    'products_attributes_weight_prefix' => $attributes_values->fields['products_attributes_weight_prefix'],
                                      
    'attributes_discounted' => $attributes_values->fields['attributes_discounted'],
                                      
    'attributes_price_base_included' => $attributes_values->fields['attributes_price_base_included'],
                                      
    'attributes_price_onetime' => $attributes_values->fields['attributes_price_onetime'],
                                      
    'attributes_price_factor' => $attributes_values->fields['attributes_price_factor'],
                                      
    'attributes_price_factor_offset' => $attributes_values->fields['attributes_price_factor_offset'],
                                      
    'attributes_price_factor_onetime' => $attributes_values->fields['attributes_price_factor_onetime'],
                                      
    'attributes_price_factor_onetime_offset' => $attributes_values->fields['attributes_price_factor_onetime_offset'],
                                      
    'attributes_qty_prices' => $attributes_values->fields['attributes_qty_prices'],
                                      
    'attributes_qty_prices_onetime' => $attributes_values->fields['attributes_qty_prices_onetime'],
                                      
    'attributes_price_words' => $attributes_values->fields['attributes_price_words'],
                                      
    'attributes_price_words_free' => $attributes_values->fields['attributes_price_words_free'],
                                      
    'attributes_price_letters' => $attributes_values->fields['attributes_price_letters'],
                                      
    'attributes_price_letters_free' => $attributes_values->fields['attributes_price_letters_free'],
                                      
    'products_options_id' => (int)$this->products[$i]['attributes'][$j]['option_id'],
                                      
    'products_options_values_id' => (int)$this->products[$i]['attributes'][$j]['value_id'],
                                      
    'products_prid' => $this->products[$i]['id']
                                      );


              
    zen_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES$sql_data_array);

              if ((
    DOWNLOAD_ENABLED == 'true') && isset($attributes_values->fields['products_attributes_filename']) && zen_not_null($attributes_values->fields['products_attributes_filename'])) {
                
    $sql_data_array = array('orders_id' => $zf_insert_id,
                                        
    'orders_products_id' => $order_products_id,
                                        
    'orders_products_filename' => $attributes_values->fields['products_attributes_filename'],
                                        
    'download_maxdays' => $attributes_values->fields['products_attributes_maxdays'],
                                        
    'download_count' => $attributes_values->fields['products_attributes_maxcount'],
                                        
    'products_prid' => $this->products[$i]['id']
                                        );

                
    zen_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD$sql_data_array);
              }
              
    //clr 030714 changing to use values from $orders->products and adding call to zen_decode_specialchars()
              //        $this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . $attributes_values->fields['products_options_values_name'];
              
    $this->products_ordered_attributes .= "\n\t" $attributes_values->fields['products_options_name'] . ' ' zen_decode_specialchars($this->products[$i]['attributes'][$j]['value']);
              
              
              
              
              
              
    //CUSTOM SERIAL SCRIPT CALL
              
    $this->products_ordered_attributes .= "\n\tProduct Setial: " getSetial($this->products[$i]['id']);
            }
          }
          
    //------eof: insert customer-chosen options ----

          // update totals counters
          
    $this->total_weight += ($this->products[$i]['qty'] * $this->products[$i]['weight']);
          
    $this->total_tax += zen_calculate_tax($total_products_price$products_tax) * $this->products[$i]['qty'];
          
    $this->total_cost += $total_products_price;

          
    $zco_notifier->notify('NOTIFY_ORDER_PROCESSING_ONE_TIME_CHARGES_BEGIN');

          
    // build output for email notification
          
    $this->products_ordered .=  $this->products[$i]['qty'] . ' x ' $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ' (' $this->products[$i]['model'] . ') ' '') . ' = ' .
          
    $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) .
          (
    $this->products[$i]['onetime_charges'] !="\n" TEXT_ONETIME_CHARGES_EMAIL $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') .
          
    $this->products_ordered_attributes "\n";
          
    $this->products_ordered_html .=
          
    '<tr>' .
          
    '<td class="product-details" align="right" valign="top" width="30">' $this->products[$i]['qty'] . '&nbsp;x</td>' .
          
    '<td class="product-details" valign="top">' $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ' (' $this->products[$i]['model'] . ') ' '') .
          
    '<nobr><small><em> '$this->products_ordered_attributes .'</em></small></nobr></td>' .
          
    '<td class="product-details-num" valign="top" align="right">' .
          
    $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) .
          (
    $this->products[$i]['onetime_charges'] !=?
          
    '</td></tr><tr><td class="product-details">' TEXT_ONETIME_CHARGES_EMAIL '</td>' .
          
    '<td>' $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') .
          
    '</td></tr>';
        }

        
    $order_total_modules->apply_credit();//ICW ADDED FOR CREDIT CLASS SYSTEM
      

    this is my code inside the function

    PHP Code:
     //CUSTOM SERIAL SCRIPT CALL
              
    $this->products_ordered_attributes .= "\n\tProduct Setial: " getSetial($this->products[$i]['id']); 

  8. #8
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Custom serial display help

    What version of Zen Cart are you using? It seems your order.php class file is a little outdated. Granted, the concept should be the same.

    Did you intentionally spell "serial" as "setial"?

    ie: getSetial()

    When your getSetial() function runs, what product number does it receive?
    What value is it programmed to return?

    What *do* your confirmation emails show? Is the "Product Setial: " text showing up?

    Remember, this only works on products with attributes.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Jul 2008
    Posts
    15
    Plugin Contributions
    0

    Default Re: Custom serial display help

    the thing is that its getting the right product number and its returning a serial number and its also marking that serial number as being viewed, i know that much is happening, but what im having trouble with is actually displaying the serial number anywhere, on the email or the order sccessfull page.

    as for the version of zencart where can i check the version, its not my store but a customer's store.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Custom serial display help

    Quote Originally Posted by Zlatko.Lakisic View Post
    but what im having trouble with is actually displaying the serial number anywhere, on the email or the order sccessfull page.
    In your custom function, what is it "returning"? ie: at the end, it should have a statement that returns the serial number.

    Quote Originally Posted by Zlatko.Lakisic View Post
    as for the version of zencart where can i check the version, its not my store but a customer's store.
    In your admin, on the top right of the menu bar is a "Version" link, or you can choose Admin->Tools->Server Info to see the same thing
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v151 Custom layout help wanted for Radio buttons with display:block or white-space:nowrap
    By dw08gm in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 21 May 2013, 03:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg