Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28
  1. #11
    Join Date
    Oct 2007
    Location
    Australia
    Posts
    843
    Plugin Contributions
    0

    Default Re: Developers API Tutorial - A Real World Example

    Is there anyone at all that might be able to help get this working? This is a functionality that x-cart for one already has and maybe other carts, though not sure if it is part of the basic functionality without an addon lol

    I am pretty sure I won't be the only person who would like to see this be a working functionality in Zen Cart :)
    HunnyBee Design
    "A man's manners are a mirror in which he shows his portrait." ~ Johann Wolfgang von Goethe

  2. #12
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Developers API Tutorial - A Real World Example

    If you want to add a product to cart with attribute, it's a very complicated matter. You may want to checkout the add form on that specific product page, and "simulate" that in your observer. For example, you can manually set $_POST values?
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  3. #13
    Join Date
    Oct 2007
    Location
    Australia
    Posts
    843
    Plugin Contributions
    0

    Default Re: Developers API Tutorial - A Real World Example

    Thanx for your reply yellow, I shall have a look and see if I can do something, I don't as yet actually know how to write this language though I have managed to stumble my way through some other things LOL
    HunnyBee Design
    "A man's manners are a mirror in which he shows his portrait." ~ Johann Wolfgang von Goethe

  4. #14
    Join Date
    Jun 2003
    Location
    Newcastle UK
    Posts
    2,930
    Plugin Contributions
    4

    Default Re: Developers API Tutorial - A Real World Example

    Hi,

    You can still use the $_SESSION['cart']->add_cart() function.
    This takes 3 parameters.

    i.e
    $_SESSION['cart']->add_cart($productId, $quantity, $attributeIds)

    The $attributeIds variable is an array of attribute option/value pairs, and you will need to build this array for yourself.

    if the option id = 5, and the value id = 10 then your array would be

    $attributeIds[5] = 10;

    Also note that for the remove/contents functions that you use, you will have to pass what is called a unique product id.

    The unique product id for a product with attributes can be calculated using

    zen_get_uprid($productId, $attributeIds)

    HTH

  5. #15
    Join Date
    Oct 2007
    Location
    Australia
    Posts
    843
    Plugin Contributions
    0

    Default Re: Developers API Tutorial - A Real World Example

    Thanx for the reply Wilt, I really appreciate it :)

    I ended up PM'ing yellow1912 and paying a small fee to get it working, which it is, and very similar to what you posted LOL my php knowledge is very limited :)
    HunnyBee Design
    "A man's manners are a mirror in which he shows his portrait." ~ Johann Wolfgang von Goethe

  6. #16
    Join Date
    Jun 2007
    Location
    Posadas, Misiones, Argentina
    Posts
    220
    Plugin Contributions
    0

    Default Re: Developers API Tutorial - A Real World Example

    Wilt, could you help me here a bit more? I'm not a php expert... and can't totally understand your post...

    I try to contact yellow1912 but don't reply me yet

    I don't know how and where add your post in my file.... could you please help me more?

    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 = 1;
     /**
      * 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 = 4660;
     /**
      * 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) {
      if ($_SESSION['cart']->show_total() >= $this->freeAmount && !$_SESSION['cart']->in_cart($this->freeProductID) ) {
       $_SESSION['cart']->add_cart($this->freeProductID);
      }
      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;
      }
     }
    }
    ?>
    thanks in advance...
    URL: http://www.littledreamswarehouse.com/shop
    Zen Version: 1.3.89h
    Zen Template: orange modified

  7. #17
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Developers API Tutorial - A Real World Example

    Wilt is sharing some helpful tools that can be used in the update function. How they are used would depend upon the specifics of what you are trying to do.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  8. #18
    Join Date
    Jun 2007
    Location
    Posadas, Misiones, Argentina
    Posts
    220
    Plugin Contributions
    0

    Default Re: Developers API Tutorial - A Real World Example

    I just want offer a free gift with a purchase... my products and gifts are only digital, only downloadable.... the file works perfectly but the download link do not appear in the order/account of my customer... so, can't download the free gift...
    URL: http://www.littledreamswarehouse.com/shop
    Zen Version: 1.3.89h
    Zen Template: orange modified

  9. #19
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Developers API Tutorial - A Real World Example

    Marta, what you will need to do is get the product ID for your gift and the option and option values its download attribute and build the attribute array as wilt suggests above. Then replace the
    $_SESSION['cart']->add_cart($this->freeProductID);
    line in the tutorial with the longer
    $productId = YOUR_PRODUCT_ID;
    $attributeIds[YOUR_OPTION_ID] = YOUR_OPTION_VALUE_ID;
    $_SESSION['cart']->add_cart($productId, 1, $attributeIds);
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  10. #20
    Join Date
    Jun 2007
    Location
    Posadas, Misiones, Argentina
    Posts
    220
    Plugin Contributions
    0

    Default Re: Developers API Tutorial - A Real World Example

    where I found my option ID and my option value ID??

    I take a look in my attributes area... and for my zip I found this:

    ID: 8229
    Option Name: Download 01
    Option Value: Download 01


    I'm still a bit confused here
    URL: http://www.littledreamswarehouse.com/shop
    Zen Version: 1.3.89h
    Zen Template: orange modified

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Error 404 accessing example.com/store in xampp tutorial
    By mbielin in forum Installing on a Windows Server
    Replies: 6
    Last Post: 11 Nov 2010, 10:24 AM
  2. Notifier/Observer problem editing Real World Example 1
    By dale88 in forum Templates, Stylesheets, Page Layout
    Replies: 23
    Last Post: 12 Mar 2010, 02:03 AM
  3. Is the Wiki Dev/API tutorial the best way to learn Zencart structure ?
    By DogTags in forum Contribution-Writing Guidelines
    Replies: 2
    Last Post: 23 Dec 2009, 03:59 PM
  4. Developers API Tutorials question
    By mipavluk in forum General Questions
    Replies: 3
    Last Post: 25 Sep 2009, 04:55 AM

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