Author Topic: MOD: Child list instead of drop down. UPDATE(1.0.11) + store wide quantity mod  (Read 459989 times)

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6)
« Reply #120 on: August 30, 2006, 15:02:04 pm »
An earlier version of my mod had multiple buttons, this could work - check back through the forum.

Another way is to alter ps_cart.php, check for 0 stock and send an email and continue the loop to check for the next item to be added, requested.

I have altered ps_cart to check multiple product_id's and this loops through, somewhere there it checks for 0 stock and redirects the page.

This would not alter the wording on the button, but it would be only 1 file to alter and it would cater for all situations.

Mark

Edit

If you check out this post

http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=17143.0

You'll find a mod to send emails requesting product info, you could use this to base your enquiry system on.
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6)
« Reply #121 on: August 30, 2006, 19:20:15 pm »
Ruby,

If you edit ps-cart and replace function add with this one

   /**
    * adds an item to the shopping cart
    * @author pablo
    * @param array $d
    */
   function add(&$d) {
      global $sess, $VM_LANG, $cart, $option, $vmLogger;

      include_class("product");
       
      $Itemid = mosgetparam($_REQUEST, "Itemid", null);
      $db = new ps_DB;
        $ci = 0;
        $request_stock = "";

      $_SESSION['last_page'] = "shop.product_details";
        //print_r($d);print_r($_SESSION['referer']);
        //Iterate through the prod_id's
        if (!isset($d["prod_id"]))
            return true;
        for ($ikey = 0; $ikey < sizeof($d["prod_id"]); $ikey++) {
       
            // Create single array from multi array
            $key_fields=array_keys($d);
            foreach($key_fields as $key) {
                if(is_array($d[$key]))
                    $e[$key] = @$d[$key][$ikey];
                else
                    $e[$key] = $d[$key];
               
                //$e[$key] = isset($d[$key][$ikey]) ? $d[$key][$ikey] : $d[$key];
                //print $key." ".$d[$key][$ikey]."<br>";               
            }
           
           $e['product_id'] = $d['product_id'];
            $e['Itemdid'] = $d['Itemid'];
            // Standard ps_cart.php with $d changed to $e
            $product_id = $e["prod_id"];
           
           
            $quantity = isset($e["quantity"]) ? $e["quantity"] : 0;
          //print $quantity;

          // Check for negative quantity
          if ($quantity < 0) {
             $vmLogger->warning( $VM_LANG->_PHPSHOP_CART_ERROR_NO_NEGATIVE );
             return False;
          }

          if (!ereg("^[0-9]*$", $quantity)) {
             $vmLogger->warning( $VM_LANG->_PHPSHOP_CART_ERROR_NO_VALID_QUANTITY );
             return False;
          }

          // Check to see if checking stock quantity
          if (CHECK_STOCK) {
             $q = "SELECT product_in_stock ";
             $q .= "FROM #__{vm}_product where product_id='$product_id'";
             $db->query($q);
             $db->next_record();
             $product_in_stock = $db->f("product_in_stock");
             if (empty($product_in_stock)) {
                $product_in_stock = 0;
             }
             if ($quantity > $product_in_stock) {
                //$msg = $VM_LANG->_PHPSHOP_CART_STOCK_1;
                //eval( "\$msg .= \"".$VM_LANG->_PHPSHOP_CART_STOCK_2."\";" );
                //$vmLogger->tip( $msg );
                //$GLOBALS['page'] = 'shop.waiting_list';
                //return true;
                    $request_stock[$ci]['product_id'] = $product_id;
                    $request_stock[$ci]['quantity'] = $quantity;
                    $ci++;
                    continue;
             }
          }


          // Quick add of item
          $q = "SELECT product_id FROM #__{vm}_product WHERE ";
          $q .= "product_parent_id = '".$product_id."'";
          $db->query ( $q );

          if ( $db->num_rows()) {
             $vmLogger->tip( $VM_LANG->_PHPSHOP_CART_SELECT_ITEM );
             return false;
          }

          // If no quantity sent them assume 1
          if ($quantity == "")
          $quantity = 1;


          // Check to see if we already have it
          $updated = 0;
      
          $result = ps_product_attribute::cartGetAttributes( $e);
       
          if ( ($result["attribute_given"] == false && !empty( $result["advanced_attribute_list"] ))
          || ($result["custom_attribute_given"] == false && !empty( $result["custom_attribute_list"] )) ) {
             $_REQUEST['flypage'] = ps_product::get_flypage($product_id);
             $GLOBALS['page'] = 'shop.product_details';
             $vmLogger->tip( $VM_LANG->_PHPSHOP_CART_SELECT_ITEM );
             return true;
          }

          // Check for duplicate and do not add to current quantity
          for ($i=0;$i<$_SESSION["cart"]["idx"];$i++) {
             // modified for advanced attributes
             if ($_SESSION['cart'][$i]["product_id"] == $product_id
             &&
             $_SESSION['cart'][$i]["description"] == $e["description"]
             ) {
                $updated = 1;
             }
          }
          // If we did not update then add the item
          if ((!$updated) && ($quantity)){

             $k = $_SESSION['cart']["idx"];

             $_SESSION['cart'][$k]["quantity"] = $quantity;
             $_SESSION['cart'][$k]["product_id"] = $product_id;
                $_SESSION['cart'][$k]["parent_id"] = $e["product_id"];
             // added for the advanced attribute modification
             $_SESSION['cart'][$k]["description"] = $e["description"];
             $_SESSION['cart']["idx"]++;
          }
          else {
             $this->update( $e );
          }

          /* next 3 lines added by Erich for coupon code */
          /* if the cart was updated we gotta update any coupon discounts to avoid ppl getting free stuff */
          if( !empty( $_SESSION['coupon_discount'] )) {
             // Update the Coupon Discount !!
             $_POST['do_coupon'] = 'yes';
          }
        } // End Iteration through Prod id's
      $cart = $_SESSION['cart'];
       
        // Added to allow iteration through request_stock array
        if (@$request_stock) {
            foreach($request_stock as $request) {
                print "Product id:".$request['product_id']." Quantity Ordered:".$request['quantity']."<br>";
                // You should change the above line to call a function to send emails
                // e.g. ps_request->request_stock_email($request['product_id'],$request['quantity']);
                // you could include a vmlogger tip function  in this to display a message to the user such as
                // $vmLogger->tip( "Stock request of ".$request['quantity'])." items requested for Product ".$request['product_id']) );
                //
            }
        }
        // End of modification

      return True;
   }

I've marked the changes in red and given some tips, hope this helps you out.

Mark
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

Davec

  • Jr. Member
  • **
  • Posts: 57
Re: MOD: Child list instead of drop down. UPDATE (1.0.6)
« Reply #122 on: August 30, 2006, 19:57:58 pm »
I was wondering how rub3licious achieved the look for the page with flourescent tape on. This is ideally what I would like to achieve for the site I am creating to sell tee shirts, sweat shirts etc...

Advice very much appreciated

Dave  ;D

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6)
« Reply #123 on: August 31, 2006, 00:30:16 am »
Davec

which part of the page??

more specific info required

I'll do what I can to help.

Mark
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

Davec

  • Jr. Member
  • **
  • Posts: 57
Re: MOD: Child list instead of drop down. UPDATE (1.0.6)
« Reply #124 on: August 31, 2006, 09:08:39 am »
Sorry Mark should have been a bit more specific  ???

It is the part where there is Option A Option B etc. followed by size colour and price qty then the add to cart button.  http://www.productionkit.co.za/index.php?page=shop.product_details&flypage=shop.flypage&product_id=82&category_id=11&manufacturer_id=0&option=com_virtuemart&Itemid=27

I must admit my original idea was something similar to this page http://www.event-shirts.co.uk/design_your_own_t-shirt.php?oscsid=d2024b53f90ee33d9c330d1cdeb76f15 again only the add to Basket part as such where there is S, M, L and you add the quantity you require. I may be wrong but I think it may involve alot of work to sort.

Dave   ;D

rub3licious

  • Beginner
  • *
  • Posts: 18
Re: MOD: Child list instead of drop down. UPDATE (1.0.6)
« Reply #125 on: September 01, 2006, 13:37:31 pm »
Hi Mark, DaveC

Wow, I 'm almost speechless, was off line for a day or two and now i'm in the habit of checking this MOD to see what's new and yeah, was so surprised to see all the fantastic stuff u put up here for me re stock requests!, just had a quick read through will go ahead and implement it now and we can see how it goes.

Thanks again Mark u have no idea what an awesome help u have been to me over the last few weeks!@#@!

DaveC: With regards to the look of the fluorescent tape page if you are only talking about the child list then... i installed Macallf's latest v1.0.6 mod and gradually tweaked it to include:
headings,
attributes,
stock levels,
only one add to cart button,
played around with the table column lengths
and now i'm busy finalising it with the add to cart changing to out of stock when 0 stock is in.

To create those various options ( eg size, colour) you need to become familiar with creating attributes and items, if you are not already. The basic concept is a parent product with children. All the information you need is on this post, as everything I achieved was done with Macallf's help. But it's quite simple:
first you create your parent product. then you add whatever attributes it needs, eg size, colour.
then you click on that parent product and begin creating items which are like children of that product, this is where option A, B, C comes in. All this is done in the product list section using the top menu.

If you search the forums there is a decent tut on that somewhere.

If you have any more specific questions once u've tried to do it then I will gladly help out where I can but it must be said that the genius around here is mark by a long shot!

Thanks again mark, good luck davec

Rube
http://www.productionkit.co.za
"Not everything that can be counted counts, and not everything that counts can be counted."
    - Albert Einstein (1879-1955)

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #126 on: September 02, 2006, 21:45:49 pm »
Hi all,

J! 1.0.11 VM 1.06

I have made quite a major modification to how this mod works which has enabled a system wide modification of the quantity box.

This means for any product in the store you can set how the quantity box is displyed.

  • Standard quantity box
  • Hidden quantity box - Value automatically set to 1
  • Drop down box - with configurable limits
  • Checkbox

The screenshot should explain this. Downloadable products are automatically set to checkbox. You can not set hide when using the list box and one addtocart button.( Will update this soon so that you can also have an addtocart button per child product)

You can now also decide if you require a table header displayed for child products.

This mod also corrects a problem with discounts. If a discount was added for a parent this was not reflected in the children. The mod now checks for discount in the children, if none is found it checks the parent.
This problem was inherent in the core VM, this also sorts it out for the standard dropdown.

I decided to add an extra tab to the add/modify product screen, as here are now so many options.
This is backwards compatible with previous mods and there are no database changes.

any problems please post.

Enjoy

Mark

[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #127 on: September 03, 2006, 00:43:57 am »
Hi All,

I've just got a working version of the multiple addtocart buttons working and have attached the files.

Consider this a BETA version. I havenot had time to fully test the multiple addtocart functionality, but I believe it is working fine.

The screen shots show the differences between the two methods.

Let me know how you get on.

Mark



[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #128 on: September 03, 2006, 15:49:26 pm »
Hi All,

I think now the last part of the mod is in place.

It occured to me that when ordering multiple products there is a possibility of ordering more than 1 out of stock item.

The system at present just exists the addtocart routine and shows you a screen asking if you wish to be notified.

I've now modified this so that it builds a list of products, when all products have been added it then shows you the notify screen with all out of stock items listed. You can check those you wish to be notified of then continue as normal.
(see screenshot)

2 extra files had to be modified and these are included in the attached zip.( This is the complete mod)

If you have any problems or can think of any improvements, please let me know.

Another oddity is that you can define different quantity boxes for child products in a list!!!
So I've added another field called Use Parent Settings If this is checked it will use the parent product settings for the children. If unset you can define the childrens quantity field individually.

Mark.


[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #129 on: September 06, 2006, 11:38:23 am »
Hi All,

yet another release!!!

  • The code I added to use the parents settings did not take account of children being displayed individually. I have tided the code for this and as a consequence use less calls.
  • I have also tied up the pathway code when on a child item. It now displays the category, the parent product and then the child product. Instead of a return to parent link, this just makes it more readable and consistent with !Joomla and VirtueMart.
  • I have also removed the link to child item when on the child item, no point - just a link to itself!!
I have not found any other inconsitencies or problems.

If you have, please let me know.

Mark

[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

Davec

  • Jr. Member
  • **
  • Posts: 57
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity mod
« Reply #130 on: September 06, 2006, 16:43:15 pm »
Well Mark you are the man no doubt about that!

Just one query really, something I need to get straight in my own mind. I have a design for some clothing. With that design there may be T Shirts, Sweats, Hooded jackets etc. Am I right to say that these can be assigned as product types for a design? Then I can add an attribute for each product type, ie Colour, Size etc? With size for instance there is small, medium, large etc can these all be added so they display individually within the size attribute!

Dave  ???

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #131 on: September 06, 2006, 17:07:00 pm »
It depends,

If you mean you have a product_type of design

then you could have advanced attributes for size & colour - although using this method you have no stock control per item .i.e. you have 100 t-shirts but then no idea how many of each colour and size.

But you can assign multiple product_types so you would create a parent of this design and add product_type attributes of type, size and colour.

It does mean creating a lot of child products, but you get the full functionality.

The included screenshot should explain, each product has a colour and size product_type, the last one has a colour of red, the same as the first, but the size is medium not small

I hope that explains it!!

[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

Davec

  • Jr. Member
  • **
  • Posts: 57
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity mod
« Reply #132 on: September 06, 2006, 17:29:43 pm »
I think I get it  ???

What I have is a design for clothing. So are the product types T shirt, Sweat Shirt etc? I am not expecting stcok control using this method but do need to be clear before I launch into adding attributes etc. I do not want drop down boxes for the sizes, so they would all basically be displayed in tabular form similar to the rub3licious  site and the tapes



Dave  :)

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #133 on: September 06, 2006, 17:37:09 pm »
In that case add them as product types

each product child would hen have several product types

see screenshot

[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #134 on: September 06, 2006, 17:46:05 pm »
Just created a product with 3 attributes

Hope this screenshot shows what is possible



[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.