.
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.
Ok thanks a lot for all of your explanations!
In fact you were right! I just tested it and buying something from a copied link doesn't add attributes at all... But as i sometimes get orders with no links, that means people use the feature... i'll try to find something that adds the attributes in the link or maybe i'll use a form.
Thanks again!
Ok, i got it to work in the all_products page.
If that interests somebody, here is my (not perfect, but working) code that has to go in line 107 of the tpl_modules_products_all_listing.php file located in your template :
It should add a buy now button and retreive and force auto-selecting of ALL the attributes for each product.PHP Code:if (PRODUCT_ALL_LIST_DESCRIPTION > '0') {
$link2 = '<form name="cart_quantity" action="index.php?main_page=product_info&products_id=' . $products_all->fields['products_id'] . '&action=add_product" method="post" enctype="multipart/form-data">';
$link2 .= '<input type="hidden" name="cart_quantity" value="1" />';
$link2 .= '<input type="hidden" name="products_id" value="' . $products_all->fields['products_id'] . '" />';
$sqllink2 = "SELECT options_id , options_values_id FROM products_attributes WHERE products_id = " . $products_all->fields['products_id'];
$resultlink2 = mysql_query($sqllink2) or die ('Erreur '.$sqllink2.' '.mysql_error());
while ($ligne = mysql_fetch_assoc($resultlink2)) {
$link2 .= '<input type="hidden" name="id[' . $ligne[options_values_id] . ']" value="'.$ligne[options_values_id].'" checked="checked" id="attrib-'.$ligne[options_values_id].'-'.$ligne[options_values_id].'" />';
}
$link2 .= '<input type="image" src="includes/templates/classic/buttons/english/button_buy_now.png" alt="Add to Cart" title=" Add to Cart " />';
$link2 .= '</form>';
$disp_text = zen_get_products_description($products_all->fields['products_id']);
$disp_text = zen_clean_html($disp_text);
$display_products_description = stripslashes(zen_trunc_string($disp_text, PRODUCT_ALL_LIST_DESCRIPTION, '<a href="' . zen_href_link(zen_get_info_page($products_all->fields['products_id']), 'cPath=' . zen_get_generated_category_path_rev($products_all->fields['master_categories_id']) . '&products_id=' . $products_all->fields['products_id']) . '"> ' . MORE_INFO_TEXT . '</a><br><br>' . $link2));
}
Hope that will help somebody.
Arno
Last edited by thysm00; 9 Feb 2010 at 05:59 PM.
A very important caveat / limitation to note: What you've shown above will FORCE the buy-now button to add ALL attributes to the cart when the product is added. Thus, the customer is NOT offered the option of deselecting any options.
While in *your* particular case that is what you wanted, it may NOT be the case for most other folks.
Also, it wouldn't surprise me that the "cart_quantity" form-name will throw HTML validation errors since you're duplicating the same form multiple times on the page. That might even cause functional problems beyond just validation matters.
So ... use at own risk.
.
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.
Yep that's true...
I'll name the forms differently. And also with a litle tweaking (letting input type="radio" instead of "hidden" and adding the name of the attribute next to it) anyone should be able to use the feature.
Bt yeah, use at your own riskI'm not really a php guru, i just do what i need, and obviously make a lot of mistakes
![]()