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

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #45 on: March 28, 2006, 21:39:06 pm »
Hi Nig,

the problem lies in the standard dropdown method of virtuemart, it checks for discount per child not based on the parent.

I have to find some way of checking each items quantity in the list and alter the discounted price based on the total quantity selected. This may take awhile to sort out, but I am looking into it.

I will get back to you when I find a solution.

If anybody else has any ideas on this it would be appreciated.

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.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #46 on: March 28, 2006, 22:29:08 pm »
Hi nig,

did not take as long as I thought!!!!

in classes/ps_cart.php change about line 168

Code: [Select]
$_SESSION['cart'][$k]["quantity"] = $quantity;
    $_SESSION['cart'][$k]["product_id"] = $product_id;
    // added for the advanced attribute modification
    $_SESSION['cart'][$k]["description"] = $e["description"];
    $_SESSION['cart']["idx"]++;

to

Code: [Select]
$_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"]++;

in classes/ps_product.php about line 1503  in function get_price change

Code: [Select]
$quantity = 0;
                for ($i=0;$i<$cart["idx"];$i++) {
if ($cart[$i]["product_id"] == $product_id) {
$quantity += $cart[$i]["quantity"];
}
}

to

Code: [Select]
$quantity = 0;
                $parent_id = "";
                $q = "SELECT product_price, product_price_id, product_currency FROM #__{vm}_product_price WHERE product_id='$product_parent_id' AND ";
$q .= "shopper_group_id='$shopper_group_id'  ORDER BY price_quantity_start";
$db->setQuery($q);
                $db->query();
if ($db->next_record()) {
                    $parent = true;
                    }
                    else {
                    $parent = false;
                }
                for ($i=0;$i<$cart["idx"];$i++) {
                    if ($cart[$i]["product_id"] == $product_id) {
                        if ($parent)
                            $parent_id  = $cart[$i]["parent_id"];
                        else
                            $quantity += $cart[$i]["quantity"];
                    }
                }
                if ($parent) {
                    for ($i=0;$i<$cart["idx"];$i++) {
                        if ($cart[$i]['parent_id'] == $parent_id) {
                            $quantity  += $cart[$i]["quantity"];
                        }
                    }
                }

This will now generate the correct discount based on the parent_id of the product instead of the product_id if the parent has prices defined.

Notes On Use

If you want discount based on individual child product do not set price in parent.
if you want discount based on total number of child products, set price in parent and not in children.

Hope this helps

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.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #47 on: March 29, 2006, 14:31:47 pm »
Hi fotoshopper,

I have got the checkbox for downloadable products finished, there are quite a few modifications to make; so here goes.

in languages/english.php

add at about line 63

Code: [Select]
var $_PHPSHOP_CART_DOWNLOAD = 'Download';
in classes/ps_product.php add this function at the end before the last '}'

Code: [Select]
function downloadable($product_id) {
    $db_check = new ps_DB;
        $q_dl = "SELECT attribute_name,attribute_value FROM #__{vm}_product_attribute WHERE ";
$q_dl .= "product_id='".$product_id."' AND attribute_name='download' ";
$db_check->query($q_dl);
$db_check->next_record();
        if ($db_check->num_rows() > 0) {
            return true;
            }
        else {
            return false;
            }
       
    }

this just checks if the product is downloadable.

in classes/ps_product_attribute.php change

Code: [Select]
$html .= $CURRENCY_DISPLAY->getFullValue($price["product_price"])."</td><td align='right'>";
                    $html .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_QUANTITY.":</label>
                            <input type=\"text\" class=\"inputbox\" size=\"4\" id=\"quantity[]\" name=\"quantity[]\" value=\"".$quantity."\" style=\"vertical-align: middle;\" />&nbsp;";
                   

about line 285

to
Code: [Select]
$html .= $CURRENCY_DISPLAY->getFullValue($price["product_price"])."</td><td align='right'>";
if ($ps_product->downloadable($db->f("product_id")) == false) {
                        $html .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_QUANTITY.":</label>
                        <input type=\"text\" class=\"inputbox\" size=\"4\" id=\"quantity".$db->f("product_id")."\" name=\"quantity[]\" value=\"".$quantity."\" style=\"vertical-align: middle;\" />&nbsp;";
                            }
                    else {
                        $html .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_DOWNLOAD.":</label>
                        <input type=\"hidden\" class=\"checkbox\" id=\"quantity".$db->f("product_id")."\" name=\"quantity[]\" value=\"".$quantity."\" />&nbsp;
                        <input type=\"checkbox\" class=\"checkbox\" id =\"check[]\" name=\"check[]\" value=\"1\" ";
                        if ($quantity > 0 )
                            $html .= "checked=\"checked\"";
                       $html .= " value=\"1\" style=\"vertical-align: middle;\" onClick=\"javascript: if(this.checked==true) document.getElementById('quantity".$db->f("product_id")."').value = 1; else {document.getElementById('quantity".$db->f("product_id")."').value=0;} \"/>&nbsp; ";
                       
                        }

in html/shop.product_details.php change

Code: [Select]
        $addtocart .= "Size: as per description</td><td>".$CURRENCY_DISPLAY->getFullValue($price["product_price"])."</td><td align='right'>
        <label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_QUANTITY.":</label>
            <input type=\"text\" class=\"inputbox\" size=\"4\" id=\"quantity[]\" name=\"quantity[]\" value=\"".$quantity."\" style=\"vertical-align: middle;\" />&nbsp;
 

about line 316 to

Code: [Select]
$addtocart .= "Size: as per description</td><td>".$CURRENCY_DISPLAY->getFullValue($price["product_price"])."</td><td align='right'>";
if ($ps_product->downloadable($db->f("product_id")) == false) {
                        $addtocart .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_QUANTITY.":</label>
                        <input type=\"text\" class=\"inputbox\" size=\"4\" id=\"quantity".$db->f("product_id")."\" name=\"quantity[]\" value=\"".$quantity."\" style=\"vertical-align: middle;\" />&nbsp;";
                            }
                    else {
                        $addtocart .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_DOWNLOAD.":</label>
                        <input type=\"hidden\" class=\"checkbox\" id=\"quantity".$db->f("product_id")."\" name=\"quantity[]\" value=\"".$quantity."\" />&nbsp;
                        <input type=\"checkbox\" class=\"checkbox\" id =\"check[]\" name=\"check[]\" value=\"1\" ";
                        if ($quantity > 0 )
                            $addtocart .= "checked=\"checked\"";
                        $addtocart .= " value=\"1\" style=\"vertical-align: middle;\" onClick=\"javascript: if(this.checked==true) document.getElementById('quantity".$db->f("product_id")."').value = 1; else {document.getElementById('quantity".$db->f("product_id")."').value=0;} \"/>&nbsp; ";
                        }

and finally in html/shop.browse.php change

Code: [Select]
$form_addtocart = "<form action=\"". $mm_action_url ."index.php\" method=\"post\" name=\"addtocart\" id=\"addtocart".$i."\">\n
                <label for=\"quantity_".$i."\">".$VM_LANG->_PHPSHOP_CART_QUANTITY.":</label>\n
                <input id=\"quantity_".$i."\" class=\"inputbox\" type=\"text\" size=\"3\" name=\"quantity\" value=\"".$quantity."\" />

about line 406 to

Code: [Select]
            $form_addtocart = "<form action=\"". $mm_action_url ."index.php\" method=\"post\" name=\"addtocart\" id=\"addtocart".$i."\">\n";
            if ($ps_product->downloadable($db->f("product_id")) == false) {
                        $form_addtocart .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_QUANTITY.":</label>
                        <input type=\"text\" class=\"inputbox\" size=\"4\" id=\"quantity".$db->f("product_id")."\" name=\"quantity[]\" value=\"".$quantity."\" style=\"vertical-align: middle;\" />&nbsp;";
                            }
                    else {
                        $form_addtocart .= "<label for=\"quantity\" style=\"vertical-align: middle;\">".$VM_LANG->_PHPSHOP_CART_DOWNLOAD.":</label>
                        <input type=\"hidden\" class=\"checkbox\" id=\"quantity".$db->f("product_id")."\" name=\"quantity[]\" value=\"".$quantity."\" />&nbsp;
                        <input type=\"checkbox\" class=\"checkbox\" id =\"check[]\" name=\"check[]\" value=\"1\" ";
                        if ($quantity > 0 )
                            $form_addtocart .= "checked=\"checked\"";
                        $form_addtocart .= " value=\"1\" style=\"vertical-align: middle;\" onClick=\"javascript: if(this.checked==true) document.getElementById('quantity".$db->f("product_id")."').value = 1; else {document.getElementById('quantity".$db->f("product_id")."').value=0;} \"/>&nbsp; ";
                        }
$form_addtocart .= "

hope this is of help to you. Check the screenshot below.

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.

cccmikey

  • Guest
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #48 on: March 29, 2006, 15:20:12 pm »
Quote
Still working on the modification for 1.0.4 If found to be working O.K. I will upload the files as a package again.

Hi Mark :) How you going with this one? :) I'm about to upgrade to 1.0.4 so not sure if I can use the existing mods again. Cheers, Mike.

Nig

  • Beginner
  • *
  • Posts: 42
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #49 on: March 29, 2006, 16:28:55 pm »
Quote
This will now generate the correct discount based on the parent_id of the product instead of the product_id if the parent has prices defined.

Notes On Use

If you want discount based on individual child product do not set price in parent.
if you want discount based on total number of child products, set price in parent and not in children.

Hope this helps

Mark

You are an absolute star!!

Can't thank you enough! Wonderful work!

Nig

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #50 on: March 29, 2006, 18:44:34 pm »
Hi cccmikey

Quote
Quote
Still working on the modification for 1.0.4 If found to be working O.K. I will upload the files as a package again.
Hi Mark  :) How you going with this one?  :) I'm about to upgrade to 1.0.4 so not sure if I can use the existing mods again. Cheers, Mike.

In the final stages of testing this on 1.0.4 if everything is OK I will post tomorrow. Still deciding whether to include all the modifications as discussed in previous posts!!!

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.

cccmikey

  • Guest
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #51 on: March 30, 2006, 00:13:07 am »
Great :) Heh with all these options you have now, you almost need your own admin section to configure them! I hope you're finding time to eat, etc! You seem flat out on these!

savage1

  • Beginner
  • *
  • Posts: 1
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #52 on: March 30, 2006, 03:04:11 am »
macallf: You do exellent job! Great thanks. That's all options i need.  :D

Is it possible to display child product in product_details list as link to full child_product page?

Thanks again ^-^

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #53 on: March 30, 2006, 03:21:13 am »
Hi savage1,

It should be possible, but it would still show all the child products as a list. The only thing that would be different is the child products image and descriptions would be used and not the parents.

Possibly the best way to do this would be a link on the childs description field!

To do that change ps_product.attribute.php at about line 249

Code: [Select]
$html .= $db->f("product_name") ."</td><td>";

// For each child get attribute values by looping through attribute list

change this to

Code: [Select]
                $flypage = $ps_product->get_flypage($db->f("product_id"));
                $url = $sess->url($mm_action_url . "index.php?page=shop.product_details&flypage=$flypage&product_id=".$db->f("product_id"));
                $html .= "<a href=\"$url\">";
$html .= $db->f("product_name") ."</a></td><td>";

// For each child get attribute values by looping through attribute list

in the globals section of the function about line 202 change

Code: [Select]
global $VM_LANG, $CURRENCY_DISPLAY,$mm_action_url;
 

to

Code: [Select]
global $VM_LANG, $CURRENCY_DISPLAY,$mm_action_url,$sess;
 

This will give you a link on each child description. Clicking update cart will however take you back to the parent.

Hope this helps

Mark

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.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #54 on: March 30, 2006, 22:09:23 pm »
Hi savage,

 in response to your message, I think this is what you want.


if you alter ps_product.attribute.php about line 238

Code: [Select]
// Start row for this child
replace this with

Code: [Select]
if (($db->f("product_id") <> $curr_product) && @$child_id)
                    continue;
// Start row for this child

and change line 207

Code: [Select]
$category_id = mosGetParam( $_REQUEST, 'category_id', "" );

to

Code: [Select]
$category_id = mosGetParam( $_REQUEST, 'category_id', "" );
        $curr_product = mosGetParam( $_REQUEST, 'product_id', "");

and change line 244

Code: [Select]
               
                    $html .= "<input type=\"hidden\" name=\"product_id\" value=\"".$parent_id."\">";
             

to

Code: [Select]
                if (@$child_id) {
                    $html .= "<input type=\"hidden\" name=\"product_id\" value=\"".$db->f("product_id")."\">"; }
                else {
                    $html .= "<input type=\"hidden\" name=\"product_id\" value=\"".$parent_id."\">";
                }

This will display a child page when the link to child is pressed. Still looking at the pathway problem but this is nearly done.

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.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #55 on: March 30, 2006, 23:59:28 pm »
Hi savage,

Found a dirty hack around your pathway problem. The pathway is made up of categories with the last parent product being displayed. This would take some reworking to work with this.

This just adds the parent to the pathway and is selectable.

change \html\shop.product_details.php after line 139

Code: [Select]
$navigation_pathway .= " ".$ps_product_category->pathway_separator()." ". $product_name;
add

Code: [Select]
  $parent_id_link = $db_product->f("product_parent_id");
  $return_link = "";
  if ($parent_id_link <> 0 ) {
    $q = "SELECT product_name FROM #__{vm}_product WHERE product_id = '$product_parent_id' LIMIT 0,1";
    $db->query( $q );
    $db->next_record();
    $product_parent_name = $db->f("product_name");
    $return_link = "Return to&nbsp;<a class=\"\" href=\"";
    $return_link .= $sess->url($_SERVER['PHP_SELF'] . "?page=shop.product_details&product_id=$parent_id_link");
    $return_link .= "\">";
    $return_link .= $product_parent_name;
    $return_link .= "</a>";
    $navigation_pathway .= " ".$ps_product_category->pathway_separator()." ". $return_link;     
    }

Hope this helps
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 Single add to cart button
« Reply #56 on: March 31, 2006, 18:43:14 pm »
Hi all

Have just updated this for VM 1.0.4

All the modifications listed on this post have been included.

  • Mulitple item discount includes child products if no price set up on child.
  • Downloadable files are displayed as a checkbox
  • Links to child products without showing other child products
  • Pathway modification to allow return to parent from above mod
  • browse page modification. Allow multiple products to be selected on browse page!
The other modifications have been discussed on this post apart from the last one.

for this there is an extra file. If the file doesn't exist there is no change to way the browse page works.

This file is in \html\templates\browse

this is the footer file. For any category that you want this mod applied to create a new file based on browse file with an extension of _footer.

i.e.
Category 1 has a browse page of browse_1.php and no footer file : this shows the page as normal
Category 2 has a browse page of browse_2.php and a footer file of browse_2_footer.php this shows this category with the new addtocart button for all products on the page.   ???

It just adds a lot more functionality to this mod, most of the work had been done anyway.

The screenshot below should explain what I mean.

Hope this all makes sense  :o

this was from a request in this post http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=13177.0

Possible further modification are to include a parameter per product that will allow you to select list or dropdown per product. Let me know what you think!!

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 Single add to cart button
« Reply #57 on: April 06, 2006, 16:23:41 pm »
Hi All,

update for this mod.

This adds a parameter to the product list to allow you to choose list or dropdown per product parent.

Basically there is a check box under the publish check box. If its checked you will have a list of child products, unchecked the standard dropdown.

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.

mosey

  • Jr. Member
  • **
  • Posts: 210
    • Zetahelp.net
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #58 on: April 10, 2006, 07:56:51 am »
Thanks to a link from gursikh on the IRC channel - I've just found out about this mod :D really impressed - thanks much for all the work macallf! :)
Back again! :) September 12th 2006

Don't worry about absolute urls! If you move your images around you can use this to update your database links!

Why not join the virtuemart IRC channel at #virtuemart on chat.freenode.net?

BigBang

  • Beginner
  • *
  • Posts: 8
Re: MOD: Child list instead of drop down. UPDATE Single add to cart button
« Reply #59 on: April 17, 2006, 08:26:15 am »
Hello, thanks for this nice Hack. My Version of Virtuemart 1.0.4 and Joomla 1.0.8

Could somebody help me out ?

I will also pay for this updated hack.

1. like to have 1 add to cart Button each line on child list
2. Like to have 1 article default into the inpotbox not 0 or current articlenumber.


THX aLot