Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Requried attribute.


Steve T

Recommended Posts

Posted

Hi Everyone!

 

I would just like to say that i a new here and have been working on an osc project for a few days now and have got to a point where i think that i need some help! :) and my eyes are starting to look like this :blink:

 

Ok what i have got running on a test system is a fresh copy of osc with the ListAttribM2_1 contribute installed.

 

On my list of products i have got the 'image','product' and 'buy now' coloums showing.

 

In the buy now coloum i have got a box to enter the quantity that you would like then i have got an attribute called 'size' (which i will talk about in a sec) and then the add to basket button.

This part works fine. I can say how many of the item i want and it works fine.

 

Now my attribute is called Size and i have 4 options in it ordered by price (By editing the SQL command in product_listing.php)

 

The options are:

 

(Select Size)

350g (?4.00)

500g (?5.50)

1Kg (?8.50)

 

As you can see only 3 of the 4 options have a price against them.

 

The way that i need this to work is so that the product has no price attached to it. But when you select the 'Size' attribute thats when you get the price.

 

So if i was to buy this product and you select 350g option then you would be charged ?4.00.

 

But the problem that im having is that you can buy this product with the 'Size' attribute set to '(Select Size)'

 

Hope this has explained it well enough! :)

 

The other thing that i would like to do is so that when you click on 'buy now' it skips going to show whats in the shopping cart and just takes you back to the product listing where you were.

 

Many thanks for any help or advice that anyone can offer!!

Steve :blink:

Posted

I recently made these kinds of modifications for a customer. Part of this is available as the must select contribution, but the installation instructions (in html) are not clear. This is the soontoberelease new version of the instructions:

The listing part is not in contribution form, but I included sample code below too.

 

MUST SELECT ATTRIBUTES
======================

Version History
---------------
v1.0 2004/11/14 By Carine Bruyndoncx ([email protected])
v1.1 2004/12/06 By Carine Bruyndoncx ([email protected])
               Rewritten installation instructions in plain text format 
               (v1.0 html format lost some of the details)

Introduction / Disclaimer
-------------------------
If you have setup your products with a dummy default options such as 'please select',
you typically still have the issue that the customers can forget to make a selection 
and add the product to the shopping cart with the 'please select' value selected.
I've been sending people these instructions lately, but as the same question keeps
popping up, I figured, better to put it in a contribution so that more people can enjoy it,
and perhaps someone else can make better installation instructions and improve the whole contribution.

This is a pretty easy install, just a few files to edit, but not yet an easy straightforward install.
The check for the missing attribute is done in the application top, based on the identifier for the 
'must select' option values id used.

ToDo / Enhancements
-------------------
- add a field on the attribute management site to say if a default 'please select' 
  must be added to the list for a particular option 
- allow the selection of another value as a default (and no must select) 
- distinguish mandatory selection of an option from optional selection 
- have all of this nicely integrated/working with the option type contribution 

Pre-requisites:
--------------
1. Take note of the option value id that you use for the 'Please select' option. 
  If you don't have this created, create such a value now and assign it to the products option 
  you are going to test with.
  You probably have to use phpmyadmin to look in the table in mysql database. The option values are
  stored in the products_options_values table. Browse and you can find the product_options_values_id.
  

Installation Instructions
-------------------------

The product info (and product listing page if you have the contribution, product listing with attributes
installed), has to check for any 'mustselect' errors.

In catalog/product_info.php page:

FIND:
   if (tep_not_null($product_info['products_model'])) {
     $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
   } else {
     $products_name = $product_info['products_name'];
   }
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

REPLACE WITH:
   if (tep_not_null($product_info['products_model'])) {
     $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
   } else {
     $products_name = $product_info['products_name'];
   }
//BoF CB Show must error messages include any must select msg
if ($messageStack->size('product_info') > 0) {
?>
       <tr>
               <td><?php echo $messageStack->output('product_info'); ?></td>
       </tr>
       <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
       </tr>
<?php  }
// EoF CB
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">



In catalog/includes/application_top.php :

FIND:
// initialize the message stack for output messages
 require(DIR_WS_CLASSES . 'message_stack.php');
 $messageStack = new messageStack;

ADD BELOW:
//BoF CB Enforce option selection
if (isset($HTTP_GET_VARS['mustselect'])){
  $error = true;
  switch ($HTTP_GET_VARS['mustselect']) {
    case 'product_info' :
     $messageStack->add('product_info','You must select a value from the options dropdown');
     break;
    case 'product_listing' :
     $messageStack->add('product_listing','You must select a value from the options dropdown for the products you are adding to cart');
     break;
  }
}
//EoF CB


In catalog/includes/application_top.php:

FIND:
    case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {


ADD BELOW: MAKE SURE TO CHANGE THE VALUE 9 TO THE IDENTIFIER FOR THE OPTION VALUE THAT YOU HAVE SETUP IN YOUR SHOP
          TO PROMPT THE CUSTOMER TO MAKE A SELECTION.
          IF YOU HAVE MULTIPLE VALUES COMMENTOUT THE SINGLE CHECK, AND USE SYNTAX THAT IS IN COMMENTS FOR MULTIPLES: 

          
                              //BoF CB Enforce attribute selection
                              if (is_array($HTTP_POST_VARS['id']) ) {
                                while (list($option, $value) = each($HTTP_POST_VARS['id'])) {
                                 //if (($value == 9) or ($value == 10) or ($value == 999) ) {
                                 // 9 is the value for "-select-"
                                 if ($value == 9) {
                                    tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'] . '&mustselect=product_info'));
                                    break;
                                 }
                                }
                              } elseif (tep_has_product_attributes($HTTP_POST_VARS['products_id'])) {
                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_POST_VARS['products_id']));
                                  break;
                              } 
                              //EoF CB


Enjoy ! 

Carine

 

Additionally, in your product_listing.php add the check for the message stack.

I don't have a stock MS2 install, but this is the code with some context, you can place it anywhere you like to show the error message:

<table bgcolor="#000000" width="100%" cellpadding="1" cellspacing="0">
<?php
//BoF CB Show must error messages include any must select msg
 if ($messageStack->size('product_listing') > 0) {
?>
        <tr>
                <td><?php echo $messageStack->output('product_listing'); ?></td>
        </tr>
        <tr>
                <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
        </tr>
<?php 
  }
// EoF CB
?>

<tr><td bgcolor="#000000">
<?php
 }

 $list_box_contents = array();

 

Then add to catalog/includes/application_top.php

 

For the buynow fix, I got this, you might need to modify this further for it to work oon your site, but you get the basic idea.

     // Multiple attributes in product listing                              
    case 'buy_now_form' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                               //BoF CB Enforce attribute selection
                               if (is_array($HTTP_POST_VARS['id']) ) {
                                 while (list($option, $value) = each($HTTP_POST_VARS['id'])) {
                                  // no longer using 0 value for no selection made
                                  // 9 is the value for "-select"
                                  if ($value == 9) {
                                    $back = sizeof($navigation->path)-1;
                                     if (isset($navigation->path[$back])) {
                                       tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_POST_VARS['products_id'] . '&mustselect=product_info'));
                                       break;
                                     }
                                	 }
                                 }
                               }
                               //EoF CB
                               $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);
// replace quantities          $cart->get_quantity($HTTP_POST_VARS['products_id'])-($cart->get_quantity($HTTP_POST_VARS['products_id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

 

Hope this gets you started,

 

Carine

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted
Hi Everyone!

 

I would just like to say that i a new here and have been working on an osc project for a few days now and have got to a point where i think that i need some help! :) and my eyes are starting to look like this  :blink:

 

Ok what i have got running on a test system is a fresh copy of osc with the ListAttribM2_1 contribute installed.

 

On my list of products i have got the 'image','product' and 'buy now' coloums showing.

 

In the buy now coloum i have got a box to enter the quantity that you would like then i have got an attribute called 'size' (which i will talk about in a sec) and then the add to basket button.

This part works fine. I can say how many of the item i want and it works fine.

 

Now my attribute is called Size and i have 4 options in it ordered by price (By editing the SQL command in product_listing.php)

 

The options are:

 

(Select Size)

350g (?4.00)

500g (?5.50)

1Kg (?8.50)

 

As you can see only 3 of the 4 options have a price against them.

 

The way that i need this to work is so that the product has no price attached to it. But when you select the 'Size' attribute thats when you get the price.

 

So if i was to buy this product and you select 350g option then you would be charged ?4.00.

 

But the problem that im having is that you can buy this product with the 'Size' attribute set to '(Select Size)'

 

Hope this has explained it well enough! :)

 

The other thing that i would like to do is so that when you click on 'buy now' it skips going to show whats in the shopping cart and just takes you back to the product listing where you were.

 

Many thanks for any help or advice that anyone can offer!!

Steve  :blink:

 

For your second question there should be a sufficient option within the Admin area:

Under Configuration-MyStore you have 'Display Cart after Adding Product'. When set to false you won't go to the shopping cart contents after a Buy Now or Add to Cart.

 

The first question I can't answer but reading the other reply/contribution made me wonder if it isn't far easier to pre-select the first real option by default so when someone clicks without choosing he/she always has a valid option ? The default could then be the one option which is choosen mostly from your experience or whatever you like most :D

And, when I create an option with the normal osCommerce possibilities this 'Select Size' is always a textual thing not interfering with the listed options you can choose. What's wrong with that or why would you wanna have this text inside the listbox ?

Forgive me if these remarks are stupid, I don't know the ListAttribM2_1 contribute ;)

Posted
For your second question there should be a sufficient option within the Admin area:

Under Configuration-MyStore you have 'Display Cart after Adding Product'. When set to false you won't go to the shopping cart contents after a Buy Now or Add to Cart.

 

Thanks for i was looking through the code and i relised that there must be switch some where i just didnt see it untill a few hours after i had posted this! lol oh well! :-"

 

Anyways! i think that i have got all the stuff working that i would like to for the mint but i will be back if i have anymore questions.

 

Thanks Again!

Steve

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...