Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24
  1. #11
    Join Date
    Feb 2010
    Posts
    23
    Plugin Contributions
    0

    Default Re: Wiki - Developer's API problem

    Has anyone have an idea why there is an error when that statement is removed. This is the error on my error log "File does not exist: /home/proje/public_html/500.shtml, referer: http://www.projects.info/2010/zencart/index.php?main_page=product_info&cPath=3_13&products_id=8"

  2. #12
    Join Date
    Feb 2010
    Posts
    23
    Plugin Contributions
    0

    Default Re: Wiki - Developer's API problem

    I really want to know how to customize the code and make modules in zen cart but there are few support for this. i can't continue learning if i can't figure out why there is an error when removing just a simple statement

  3. #13
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Wiki - Developer's API problem

    Quote Originally Posted by dale88 View Post
    Has anyone have an idea why there is an error when that statement is removed. This is the error on my error log "File does not exist: /home/proje/public_html/500.shtml, referer: http://www.projects.info/2010/zencart/index.php?main_page=product_info&cPath=3_13&products_id=8"
    The "500.shtml" file is called when the server encounters a "500" error, and the 500.shtml file is used to display that error message to the browser. Evidently you don't have such a file, so the error cannot be displayed. Hence the "file does not exist" message you're seeing.

    A "500" error is a "Internal Server Error", which is triggered by the webserver, and not by Zen Cart. The reasons for triggering the error are documented in the server's apache errorlog. You may have to ask your hosting company for access to that information.
    .

    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.

  4. #14
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Wiki - Developer's API problem

    As to why removing a line of code is causing you some errors, it's very difficult to troubleshoot what syntax problems you may have introduced by making changes.
    .

    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. #15
    Join Date
    Feb 2010
    Posts
    23
    Plugin Contributions
    0

    Default Re: Notifier/Observer problem editing Real World Example 1

    I know the problem is an internal server error. my problem is what is causing that
    PHP Code:
    <?php
    /**
     * Observer class used to add a free product to the cart if the user spends more than $x
     *
     */
    class freeProduct extends base {
      
    /**
       * The threshold amount the customer needs to spend.
       * 
       * Note this is defined in the shops base currency, and so works with multi currency shops
       *
       * @var decimal
       */
      
    var $freeAmount 50;
      
    /**
       * The id of the free product.
       * 
       * Note. This must be a true free product. e.g. price = 0 Also make sure that if you don't want the customer
       * to be charged shipping on this, that you have it set correctly.
       *
       * @var integer
       */
      
    var $freeProductID 57;
      
    /**
       * constructor method
       * 
       * Attaches our class to the $_SESSION['cart'] class and watches for 2 notifier events.
       */
      
    function freeProduct() {
        
    $_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END''NOTIFIER_CART_REMOVE_END'));
      }
      
    /**
       * Update Method
       * 
       * Called by observed class when any of our notifiable events occur
       *
       * @param object $class
       * @param string $eventID
       */
      
    function update(&$class$eventID$paramsArray = array()) {
      
        if (
    $eventID == 'NOTIFIER_CART_REMOVE_END' && (isset($_SESSION['freeProductInCart']) && $_SESSION['freeProductInCart'] == TRUE ))
      {
        if (!
    $_SESSION['cart']->in_cart($this->freeProductID))
        {
          
    $_SESSION['userRemovedFreeProduct'] = TRUE;
        }
      }

      if (!isset(
    $_SESSION['userRemovedFreeProduct']) || $_SESSION['userRemovedFreeProduct'] != TRUE
      {
        if (
    $_SESSION['cart']->show_total() >= $this->freeAmount && !$_SESSION['cart']->in_cart($this->freeProductID) ) // when this statement is removed i get an error  
        
    {    
          
          
    $_SESSION['cart']->add_cart($this->freeProductID);
          
    $_SESSION['freeProductInCart'] = TRUE;  
        }
      }
     
      if (
    $_SESSION['cart']->show_total() < $this->freeAmount && $_SESSION['cart']->in_cart($this->freeProductID) ) 
      {
        
    $_SESSION['cart']->remove($this->freeProductID);
      }

     
      if (
    $_SESSION['cart']->in_cart($this->freeProductID)) 
      {
        
    $_SESSION['cart']->contents[$this->freeProductID]['qty'] = 1;
      }
       
      }  
    }

    ?>
    I was experimenting on this code on WIKI API tutorial. i tried to remove this condition statement " if ($_SESSION['cart']->show_total() < $this->freeAmount && $_SESSION['cart']->in_cart($this->freeProductID) )
    {
    " that is when the error comes up when i'm trying to add a product in the cart. i scanned shopping cart class and still haven't figured why it has to have that statement for the class to work

  6. #16
    Join Date
    Feb 2010
    Posts
    23
    Plugin Contributions
    0

    Default Re: Notifier/Observer problem editing Real World Example 1

    i hope you don't mind testing this on your zen cart test site

  7. #17
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Notifier/Observer problem editing Real World Example 1

    Quote Originally Posted by dale88 View Post
    I was experimenting on this code on WIKI API tutorial. i tried to remove this condition statement " if ($_SESSION['cart']->show_total() < $this->freeAmount && $_SESSION['cart']->in_cart($this->freeProductID) )
    {
    " that is when the error comes up when i'm trying to add a product in the cart. i scanned shopping cart class and still haven't figured why it has to have that statement for the class to work
    But ... an "if" clause which contains an opening brace { must also include a closing brace }
    And, if you only removed the "if" condition and its opening brace, then you've created an ugly PHP error situation.
    If you really want to remove that particular "if" clause, you need to remove the *whole* thing:
    Code:
      if ($_SESSION['cart']->show_total() < $this->freeAmount && $_SESSION['cart']->in_cart($this->freeProductID) ) 
      {
        $_SESSION['cart']->remove($this->freeProductID);
      }
    I recommend going back to the PHP website and studying the code syntax before adjusting further PHP code.
    .

    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.

  8. #18
    Join Date
    Feb 2010
    Posts
    23
    Plugin Contributions
    0

    Default Re: Notifier/Observer problem editing Real World Example 1

    Yes i know it will cause php errors if you don't remove the closing bracket. i removed the condition including the closing bracket.

    so the script looks like this
    PHP Code:
    <?php
    /**
     * Observer class used to add a free product to the cart if the user spends more than $x
     *
     */
    class freeProduct extends base {
      
    /**
       * The threshold amount the customer needs to spend.
       * 
       * Note this is defined in the shops base currency, and so works with multi currency shops
       *
       * @var decimal
       */
      
    var $freeAmount 100;
      
    /**
       * The id of the free product.
       * 
       * Note. This must be a true free product. e.g. price = 0 Also make sure that if you don't want the customer
       * to be charged shipping on this, that you have it set correctly.
       *
       * @var integer
       */
      
    var $freeProductID 15;
      
    /**
       * constructor method
       * 
       * Attaches our class to the $_SESSION['cart'] class and watches for 2 notifier events.
       */
      
    function freeProduct() {
        
    $_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END''NOTIFIER_CART_REMOVE_END'));
      }
      
    /**
       * Update Method
       * 
       * Called by observed class when any of our notifiable events occur
       *
       * @param object $class
       * @param string $eventID
       */
      
    function update(&$class$eventID$paramsArray = array()) {

      if (
    $eventID == 'NOTIFIER_CART_REMOVE_END' && (isset($_SESSION['freeProductInCart']) && $_SESSION['freeProductInCart'] == TRUE ))
      {
        if (!
    $_SESSION['cart']->in_cart($this->freeProductID))
        {
          
    $_SESSION['userRemovedFreeProduct'] = TRUE;
        }
      }

      if (!isset(
    $_SESSION['userRemovedFreeProduct']) || $_SESSION['userRemovedFreeProduct'] != TRUE
      {

          
    $_SESSION['cart']->add_cart($this->freeProductID);
          
    $_SESSION['freeProductInCart'] = TRUE;  
        }
      
     
      if (
    $_SESSION['cart']->show_total() < $this->freeAmount && $_SESSION['cart']->in_cart($this->freeProductID) ) 
      {
        
    $_SESSION['cart']->remove($this->freeProductID);
      }

      if (
    $_SESSION['cart']->in_cart($this->freeProductID)) 
      {
        
    $_SESSION['cart']->contents[$this->freeProductID]['qty'] = 1;
      }
       
      }  
    }
    ?>

  9. #19
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Notifier/Observer problem editing Real World Example 1

    Maybe because you're removing some critical logic which protects against re-adding the item to the cart if it's already there? perhaps thus causing an endless loop?

    I'm not sure why you would choose to remove that part of the logic in the first place.
    .

    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.

  10. #20
    Join Date
    Feb 2010
    Posts
    23
    Plugin Contributions
    0

    Default Re: Notifier/Observer problem editing Real World Example 1

    I got you. i wanna know the details why is that statement important on the logic. I'm just experimenting the code for learning reasons. Can't seem to find out why is that statement caused errors when removed. all its do is check if amount is more than the free amount. for me, when that statement is removed it should automatically adds the free product on the cart regardless of the amount in the cart. that's what i think the program flow is.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v151 Multiple Observer Classes for Same Notifier Event
    By Dave224 in forum General Questions
    Replies: 6
    Last Post: 8 Jul 2013, 11:07 PM
  2. Observer Notifier NOTIFIER_CART_GET_PRODUCTS_END Help
    By Celtic in forum General Questions
    Replies: 2
    Last Post: 9 Jun 2011, 11:22 PM
  3. Developers API Tutorial - A Real World Example
    By LissaE in forum General Questions
    Replies: 27
    Last Post: 11 Oct 2010, 02:57 PM
  4. observer/notifier the "base" class
    By David Bo in forum Basic Configuration
    Replies: 1
    Last Post: 3 Apr 2007, 02:23 AM
  5. Is notifier/observer system good for this?
    By s_p_ike in forum General Questions
    Replies: 5
    Last Post: 7 Aug 2006, 10:16 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