Jump to content

insomniac2

Members
  • Content count

    406
  • Joined

  • Last visited

  • Days Won

    1

Reputation Activity

  1. Downvote
    insomniac2 got a reaction from acaso in How to show cost of each attribute in cart and order   
    Here is the infobox table code I modded to show attributes. You can use it for code and as an example. It is too reworked to just use ... but the attribute code areas should give you the idea.
     
    <?php
    if ($cart->count_contents() > 0) {
    ?>
    <tr>
    <td>
    <?php
    $info_box_contents = array();
    $info_box_contents[0][] = array('align' => 'center',
    'params' => 'class="productListing-heading"',
    'text' => TABLE_HEADING_REMOVE);
     
    $info_box_contents[0][] = array('params' => 'class="productListing-heading"',
    'text' => '   ' . TABLE_HEADING_PRODUCTS);
     
    $info_box_contents[0][] = array('align' => 'center',
    'params' => 'class="productListing-heading"',
    'text' => TABLE_HEADING_QUANTITY);
     
    $info_box_contents[0][] = array('align' => 'right',
    'params' => 'class="productListing-heading"',
    'text' => TABLE_HEADING_TOTAL);
     
    $any_out_of_stock = 0;
    $products = $cart->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
    // Push all attributes information in an array // DO NOT USE (int) on $products[$i]['id'] or cart loses products attributes
    if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
    while (list($option, $value) = each($products[$i]['attributes'])) {
    echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . (int)$option . ']', (int)$value);
    $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'");
    $attributes_values = tep_db_fetch_array($attributes);
     
    $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
    $products[$i][$option]['options_values_id'] = $value;
    $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
    $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
    $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
    }
    }
    }
     
    // change dropdown
    //for ($i=0; $i < NUM_PROD_MAXORD; $i++) {
     
    //$options[$i][id] = ($i+1); // modified these 2 lines so dropdown starts at 0
    //$options[$i][text] = ($i+1);
    //$options[$i][id] = ($i);
    //$options[$i][text] = ($i);
    //}
    for ($j=0 ; $j < NUM_PROD_MAXORD; $j++) {
     
    //$options[$j][id] = ($j+1); // modified these 2 lines so dropdown starts at 0
    //$options[$j][text] = ($j+1);
    $options[$j][id] = ($j);
    $options[$j][text] = ($j);
    }
    // end change dropdown
     
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
    if (($i/2) == floor($i/2)) {
    $info_box_contents[] = array('params' => 'class="productListing-even"');
    } else {
    $info_box_contents[] = array('params' => 'class="productListing-odd"');
    }
     
    $cur_row = sizeof($info_box_contents) - 1;
     
    $info_box_contents[$cur_row][] = array('align' => 'center',
    'params' => 'class="productListing-data" valign="middle"',
    'text' => '<a href="' . tep_href_link(basename($PHP_SELF), 'action=remove_product&products_id=' . $products[$i]['id'] . '', 'NONSSL') . '">' . tep_image_button('remove_item.gif', TEXT_REMOVE_ITEM) . '</a>');
    //'text' => '<br>' . tep_image_submit('remove_item.gif', IMAGE_BUTTON_UPDATE_CART) . ' ' . tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'], ' ', 'onFocus="advisecustomer();"'));
     
    $products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
    ' <tr>' .
    ' <td class="productListing-data" align="left"></td>' .
    ' <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['model'], 50, 45) . '</a></td>' .
    // original line below does not show model
    //' <td class="productListing-data" valign="top"> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>' . '<br><br> Manufacturer: ' . $mfg['manufacturers_other'] . ' ' . $mfg['manufacturers_name'];
    ' <td class="productListing-data" align="left">  </td>' .
    ' <td class="productListing-data" valign="top"> <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</a></b>  <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_ICONS . 'icon_info.gif', TEXT_VIEW_PRODUCT) . '</a>';
     
    // BEGIN Minimum Product Quantity
    if (MINIMUM_ORDERS == 'true') {
    $min_order_query = tep_db_query("select p.minorder as min_quant from " . TABLE_PRODUCTS . " p where p.products_id = '" . $products[$i]['id'] . "'");
    while ($min_order = tep_db_fetch_array($min_order_query)) {
    if ($products[$i]['quantity'] < $min_order['min_quant']) {
    $products[$i]['min_quant'] = $min_order['min_quant'];
    }
    }
     
    if ($products[$i]['quantity'] < $products[$i]['min_quant']) {
    $products[$i]['quantity'] = $products[$i]['min_quant'];
    //$cart->add_cart($products[$i]['id'], $products[$i]['quantity']);
    $cart->add_cart($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']);
    echo '<small><font color="FF0000">' . sprintf(MINIMUM_ORDER_NOTICE, $products[$i]['name'], $products[$i]['min_quant'] . '</small></font>');
    tep_redirect(tep_href_link(basename($PHP_SELF))); // added to update total correctly when updates minimum quantity allowed
    //tep_redirect(tep_href_link(basename($PHP_SELF))); // need to incorporate this so display totals are updated on quantity notice change ... else the sub-total does not reflect the changes
    }
    }
     
    if (($products[$i]['min_quant'] > 0) && (MINIMUM_ORDERS == 'true')) {
    $products_name .= '  <small><font color="FF0000">[ Minimum Qty. of ' . $products[$i]['min_quant'] . ' ]' . '</small></font>';
    }
    // END Minimum Product Quantity
     
    // show the model name and number
    $products_name .= '<br> Model Number: [ ' . $products[$i]['model'] . ' ]</small>';
     
    // Begin Show Manufacturer In Listing
    $v_query = tep_db_query("select manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . $products[$i]['id'] . "'");
    $v = tep_db_fetch_array($v_query);
    // Select the proper Manufacturers Name via the Manufacturers ID# then display that name for a human readable output
    $mfg_query = tep_db_query("select manufacturers_id, manufacturers_other, manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . $v['manufacturers_id'] . "'");
    $mfg = tep_db_fetch_array($mfg_query);
     
    if (tep_not_null($mfg['manufacturers_id'])) {
    $products_name .= '<br> ' . TEXT_MANUFACTURER . ' ' . $mfg['manufacturers_other'] . ' ' . $mfg['manufacturers_name'];
    } else {
    $products_name .= '<br> ' . TEXT_MANUFACTURER_UNAVAILABLE;
    }
    // End Show Manufacturer In Listing
     
    /// BEGIN Country_based_shipping
    $check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");
    $check_country = tep_db_fetch_array($check_country_query);
     
    $my_shipping_geo_query = tep_db_query("select products_geo_zones from " . TABLE_PRODUCTS . " where products_id = '" . $products[$i]['id'] . "'");
    $my_shipping_geo = tep_db_fetch_array($my_shipping_geo_query);
     
    $check_geo_zone_query = tep_db_query("select zone_country_id, zone_id, geo_zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where zone_country_id = '" . (int)$check_country['entry_country_id'] . "' and zone_id = '" . (int)$check_country['entry_zone_id'] . "' and geo_zone_id = '" . (int)$my_shipping_geo['products_geo_zones'] . "'");
    $check_geo_zone = tep_db_fetch_array($check_geo_zone_query);
     
    if (!tep_session_is_registered('customer_id')) {
    } else {
    if ($my_shipping_geo['products_geo_zones'] != $check_geo_zone['geo_zone_id'] && $my_shipping_geo['products_geo_zones'] != 0) {
    //$products_name .= '<br> ' . TEXT_PRODUCT_NOT_AVAILABLE_FOR_SHIPPING_HERE;
    $products_name .= '<br> ' . '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . TEXT_PRODUCT_NOT_AVAILABLE_FOR_SHIPPING_HERE . '</b></a>  ' . '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '">' . tep_image_button('button_change_shipping_address.gif', TEXT_CHANGE_SHIPPING_ADDRESS, 'align="absbottom"') . '</a>';
    }
    }
    /// END Country_based_shipping
     
    if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
    reset($products[$i]['attributes']);
    while (list($option, $value) = each($products[$i]['attributes'])) {
    $products_name .= '<br><small> <i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
     
    // begin show options values in cart mod
    if ($products[$i][$option]['options_values_price'] > 0) {
    $products_name .= ' + $' . sprintf("%01.2f", $products[$i][$option]['options_values_price']);
    }
    // end show options values in cart mod
     
    $products_price = '<span class="smallText"><b>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</font></b>   ';
    }
    }
     
    // show the per unit price
    $products_name .= '<br><br> <small>Base Price: ' . $currencies->display_price_nodiscount($products[$i]['price'], tep_get_tax_rate($products[$i]['tax_class_id']), 1) . '</small>';
     
    // Low Stock Warning
    if (STOCK_CHECK == 'true') {
    $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
    if (tep_not_null($stock_check)) {
    $any_out_of_stock = 1;
     
    $products_name .= $stock_check . ' ' . $products[$i]['name'];
    }
    }
     
    $products_name .= ' </td>' .
    ' </tr>' .
    '</table>';
     
    $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"',
    'text' => '<br>' . $products_name);
     
    $info_box_contents[$cur_row][] = array('align' => 'center',
    'params' => 'class="productListing-data" valign="top"',
    //'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));
    // begin change dropdown
    'text' => '<br>' . tep_draw_pull_down_menu('cart_quantity[]', $options, $products[$i]['quantity'], 'onchange="this.form.submit();" onFocus="update_qty_warning();"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));
    // end change dropdown
     
    //$info_box_contents[$cur_row][] = array('align' => 'right',
    //'params' => 'class="productListing-data" valign="top"',
    //'text' => '<br>Unit Price: <b>' . $currencies->display_price($products[$i]['price'], tep_get_tax_rate($products[$i]['tax_class_id']), 1 ) . '</b> <br><br><font color="0000FF">Total:</font> <b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b> ');
     
    // BEGIN Group Discount
    $info_box_contents[$cur_row][] = array('align' => 'right',
    'params' => 'class="productListing-data" valign="top"',
    'text' => '<br>Unit Price: <b>' . $currencies->display_price_nodiscount($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax']), 1) . '</b> <br><br><font color="0000FF">Total:</font> <b>' . $currencies->display_price_nodiscount($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b> ');
    // END Group Discount
     
    }
     
    new productListingBox($info_box_contents);
    ?>
×