Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20
  1. #11
    Join Date
    Jan 2008
    Posts
    1,700
    Plugin Contributions
    6

    Default Re: Direct price entry attribute?

    I'm also interested in the slider function and letting the customer choose their price.

  2. #12
    Join Date
    Mar 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    Ditto for me.

    Need a way for customers to submit offers on products. Don't need the slider, but just getting to see what you've changed would be immensely helpful to me figuring it out myself.

  3. #13
    Join Date
    Jun 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    I too am very interested in this option

    i sell custom gift hampers and need the customer to be able to specify what price they want to spend up to.

    I like the slider option too, so dont mind if its still got that.

  4. #14
    Join Date
    Mar 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    Ok...

    So I scraped something together to make this work... Kinda.

    This isn't exactly perfect, as it relies on customer input in a text field, and currently I'm not filtering the values down to numerical only. Hopefully I"ll have time to work that part out next week.


    I had to edit /includes/classes/shopping_cart.php


    I had to add things to two areas of the file. If anyone looks at this and knows of ways to tweak it to make it work better, by all means, let me know! I knew nothing at all about the actual PHP coding language as of about a month ago, and didn't ACTUALLY dig into it until I started trying to figure this out a week and a half ago. I'm sure it's fairly hackish, but it gets the job done. I'd love to make it cleaner if possible though.

    I've been tweaking the file, so the line numbers might not be exactly standard anymore...


    Note, the 4 in
    Code:
    $attribute_price->fields['options_id'] == 4
    Is the options_id value that goes with the option name you're using. So if your have an option name called "Donation Amount", check the option ID for that option, and use that number in those locations. That should be the only variable thing in this code... iirc.


    But right around line 700:

    I changed this
    Code:
    // bottom total
              //            if ($attribute_price->fields['product_attribute_is_free']) {
              if ($attribute_price->fields['product_attribute_is_free'] == '1' and zen_get_products_price_is_free((int)$prid)) {
                // no charge for attribute            
              } else {
                // + or blank adds




    To this


    Code:
    // bottom total
              //            if ($attribute_price->fields['product_attribute_is_free']) {
              if ($attribute_price->fields['product_attribute_is_free'] == '1' and zen_get_products_price_is_free((int)$prid)) {
                // no charge for attribute
                
              	
              } elseif ($attribute_price->fields['options_id'] == 4) {
                $attr_value = $this->contents[$products_id]['attributes_values'][$option];
                $this->total += $qty * ($attr_value - $products_price);
                               
               } else {
                // + or blank adds


    That edits the total at the bottom of the page, but not the price/total on each line for the items.

    To do that, I had to tweak the attributes function, and the SQL query at the beginning of it.



    Around line 850 or so (I added big multi-line /////////comment flags///////) around my stuff, to mark it clearly for myself, so my lines might be off a bit.. But around 850, I added the products table to the query, so I can call the product price variable.

    The query statement now looks like this (added 3rd and 4th line, tweaked 5th from where to and):

    Code:
            $attribute_price_query = "select *
                                        from " . TABLE_PRODUCTS_ATTRIBUTES . "
                                        inner join " . TABLE_PRODUCTS . "
                                        where " . TABLE_PRODUCTS . ".products_id = " . TABLE_PRODUCTS_ATTRIBUTES . ".products_id
                                        and " . TABLE_PRODUCTS_ATTRIBUTES . ".products_id = '" . (int)$products_id . "'
                                        and " . TABLE_PRODUCTS_ATTRIBUTES . ".options_id = '" . (int)$option . "'
                                        and " . TABLE_PRODUCTS_ATTRIBUTES . ".options_values_id = '" . (int)$value . "'";



    And around 890, I added a similar block of code to the change I made around line 700.

    Went from this:

    Code:
      // calculate proper discount for attributes
                  $discount_type_id = '';
                  $sale_maker_discount = '';
                  $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
                  $attributes_price += ($new_attributes_price);
                }  else {
                  $attributes_price += $attribute_price->fields['options_values_price'];
                }
              }
    							
              //////////////////////////////////////////////////
              // calculate additional charges
              // products_options_value_text


    To this:


    Code:
     // calculate proper discount for attributes
                  $discount_type_id = '';
                  $sale_maker_discount = '';
                  $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
                  $attributes_price += ($new_attributes_price);
                }  else {
                  $attributes_price += $attribute_price->fields['options_values_price'];
                }
              }
              
    		
            $products_price = $attribute_price->fields['products_price'];
                    		
           		 if ($attribute_price->fields['options_id'] == 4) {
            		$attr_value = $this->contents[$products_id]['attributes_values'][$option];
    				$attributes_price += ($attr_value - $products_price);
    				}
    							
              //////////////////////////////////////////////////
              // calculate additional charges
              // products_options_value_text


    That might not be the BEST way to do it, but it's working for me. It adds the whatever they put in the blank to the product price as an attributes charge. If you set your initial product price as 0, it would then be the only thing setting the price for the product. If your initial minimum donation is... 10 bucks... and they put in 20... it will charge 20... not 30. If you wanted it to ADD to the price, rather than replace it... just take the "- $products_price" parts out of the math equations in the first and 3rd bits of custom code.


    Our operation isn't overly automated, so this works well enough for it, as we check every order carefully anyways, even as is... BUT, it doesn't filter the input for numerical values only, and if they even use so much as a $ before the price they put in, it will treat it as if they entered 0 for the value. I don't think that would actually take too much to just throw a filter on the backend of it to clean up things like a dollar sign throwing it off... But I want to actually block them from adding things to the shopping cart unless the input is valid after filtering, and I think that's going to take me considerably more work to get that figured out.
    Last edited by Teeb; 20 Jun 2008 at 04:19 PM.

  5. #15
    Join Date
    Mar 2008
    Posts
    21
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    Bah, timer just ran out on editing when I had one last change to make for clarification:



    That might not be the BEST way to do it, but it's working for me. It adds the difference between whatever they put in the attributes blank and the product price (attr_value - product_price) back to the product price as an attributes charge. If you set your initial product price as 0, it would then be the only thing setting the price for the product. If your initial minimum donation is... 10 bucks... and they put in 20... it will charge 20... not 30. If you wanted it to ADD to the price, rather than replace it... just take the "- $products_price" parts out of the math equations in the first and 3rd bits of custom code.




    I would love to get some feedback on this, as it's the first functional coding I've ever done in PHP.

  6. #16
    Join Date
    Nov 2007
    Posts
    68
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    Can you explain how you did this?
    _X_|_X_|_X_|_X_|_X_|_X_|_X_|_X_|_X_|_X_|_X_|_X_|_X_|

    Judah

    WORK YOUR BUSINESS LIKE IT IS ALL UP TO YOU....PRAY FOR YOUR BUSINESS LIKE IT IS ALL UP TO GOD
    QUOTE BY: UNKNOWN

  7. #17
    Join Date
    Mar 2006
    Posts
    919
    Plugin Contributions
    2

    Default Re: Direct price entry attribute?

    Quote Originally Posted by Teeb View Post
    I would love to get some feedback on this, as it's the first functional coding I've ever done in PHP.
    Just wanted to say thanks for posting your findings.

    I managed to implement your solution with no problems and it's working really well! :)

  8. #18
    Join Date
    Mar 2007
    Location
    Pepperell, Massachusetts
    Posts
    232
    Plugin Contributions
    1

    Default Re: Direct price entry attribute?

    Any improvements recently?

  9. #19
    Join Date
    Jul 2005
    Posts
    35
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    sorry - deleted
    Tony

  10. #20
    Join Date
    Jul 2008
    Posts
    36
    Plugin Contributions
    0

    Default Re: Direct price entry attribute?

    I'm just implementing this mod - it seems to work perfectly (thank you Teeb!) except that I want my initial price to be the minimum value they can enter. With Teeb's code, if your initial value is 10 and they enter 2, it overrides the 10 with a 2.

    I have modded the following two lines of Teeb's code so it will replace the initial value with the value they enter only if it is greater than the initial value.

    The lines are

    Code:
    $this->total += $qty * (max(($attr_value - $products_price), 0));
    and

    Code:
    $attributes_price += (max(($attr_value - $products_price), 0));
    from the first and third custom pieces Teeb provided.

    Hope this is useful to someone

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Add base price to attribute price so that attribute shows total amount
    By dcitsolutions in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 18 Nov 2010, 08:56 AM
  2. Need attribute price to display total price not incremental price
    By Rickk123 in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 2 Sep 2010, 06:26 PM
  3. Direct entry monetary value
    By dhcernese in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 12 Mar 2009, 01:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg