Post by radke » Tue Jul 27, 2010 11:25 pm

I've recently setup an opencart site for nonprofit organization. Being nonprofit they are very interested in accepting donations through opencart alongside various items they sell.

So I guess I'm looking for a way to add products (paypal donations) to the catalog that'll allow the customer to enter their own price (donation) amount.

I imagine that allowing customers to enter their own price would be helpful in many cases. Anyone have any ideas on how to accomplish this?

Thanks in advance!

Newbie

Posts

Joined
Tue Jul 27, 2010 10:59 pm

Post by JAY6390 » Wed Jul 28, 2010 12:17 am

Why not have a "donation" product that is say $1, then just get people to add the quantity they want to donate into the quantity box, so 20 in the quantity box will equate to $20

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by Qphoria » Wed Jul 28, 2010 1:46 am

Ive done something like this for a gift certificate shop back in 1.3.4
i'll see what I can dig up

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by sparkybarkalot » Sat Oct 30, 2010 12:40 am

Qphoric,

Were you able to dig anything up? I'm in the same boat: working on a cart for a public library and part of what they do is solicit donations in price ranges:

Library Donor: $1 - $99
Library Patron: $100 - $499
Chairman's Circle: $500 - blah blah blah

Currently users can enter their own dollar amounts, and I'd love to continue that. Any thoughts? Thanks for any help/suggestions you can offer.


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by Qphoria » Sat Oct 30, 2010 2:51 am

This should do it

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by sparkybarkalot » Sat Oct 30, 2010 2:59 am

That is AWESOME. Thanks so much. I'll give it a try and report back.


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by sparkybarkalot » Sat Oct 30, 2010 4:32 am

Q, I am having some problems, and not sure where the issue may lie

1) I'm unable to remove from my cart any items that have the "custom" SKU and been added to the cart, regardless of whether I entered a custom amount or choose the default price choice

2) Both the Shopping Cart page and the Cart module show "custom" as an added item, even when the customer does not enter a custom price. If a custom price IS added by a user (for example, $33) then the Shopping Cart and cart module show "custom 33" which would be fine except that...

3) In addition to the custom price being added to the cart, the item in the dropdown is ALSO added to the cart. For example, if I have two contribution levels (Donor at $100 and Contributor at $500, let's say) and Donor is sort level 1 so it's the "default" item in the dropdown, and I ONLY enter 33 in the custom field... then TWO items are added: 1 that says "Contributor Level Donor" for $100 and "custom 33" for $33.

Any quick ideas on how to fix this? I realize you were making a quick helpful solution, so I don't want to abuse your goodwill. I would gladly make a donation to get this resolved.


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by sparkybarkalot » Sat Oct 30, 2010 4:41 am

Perhaps I shouldn't be trying to use any options in this case... but even doing that, I'm still unable to remove an added product with and SKU of "custom" from the cart


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by sparkybarkalot » Sat Oct 30, 2010 11:33 pm

Q,

I was able to make two small changes to your code in system/library/cart.php to get it to work:

1) Added an IF statement so that the word "custom" wasn't added to the cart display when a custom price was not entered by a customer (in other words, when the customer was happy with the default price)

2) Instead of using "custom_" at the beginning of the option name, I changed it to "custom-". I did that because the callback function of the cart module explodes on the underscore character, so the original underscore you had after "custom" was causing problems when trying to remove the item from the cart module (not in the cart's "Remove" checkbox, which was working just fine).

Seems to work now, though it hasn't been fully and completely tested! I edited your file and attached the fix.


Posts

Joined
Thu Dec 24, 2009 12:03 am

Post by kpdirection » Fri Apr 29, 2011 12:29 pm

Is there a version which works with 1.4.9.4?

I tried Sparkybarkalot's version, and get an error on system/library/cart.php, as there is no value in $optdata[1] (I may have the product set up incorrectly, of course.. )

Any clues?

Thanks.

Peter Connolly
Technical Director
KP Direction LLC
White-Label Drupal and PHP Development for Media Companies
http://www.kpdirection.com
USA, UK, Canada


New member

Posts

Joined
Mon Apr 18, 2011 12:14 pm

Post by unknownmale1 » Fri Oct 21, 2011 7:06 pm

Anything like this for 1.5+ ?

Active Member

Posts

Joined
Sat Aug 28, 2010 6:46 pm

Post by RuralSquirrel » Tue Sep 25, 2012 10:12 am

Hi all,
Would love to know if user-defined amounts for a product is available for OC 1.5+
I understand that there's a charity module out there, but the only way it works is if a customer has already added a product to their cart. If a potential user only wants to donate, it can't be done.
Is there anyway to take a mandatory product text option, convert it to the currency of the store and add the product with that price to the cart? I'd pay for that extension.
Thanks so much!
Mindy : )

Newbie

Posts

Joined
Tue Jul 31, 2012 12:51 pm

Post by signereign » Wed Dec 19, 2012 5:45 am

Modified the code to work with OC 1.5.4. For this to work you will have to create an option type "text" and named "amount" then add it to the product.

BACK UP FILES BEFORE YOU EDIT! alternatively, you can make this a VQMOD

EDIT BEGINS:
1. open /system/library/cart.php
3. look for elseif ($option_query->row['type'] == 'text' (this is under getProducts() function)
4. inside that if-else block replace:

Code: Select all

$option_data[] = array(
    'product_option_id'       => $product_option_id,
    'product_option_value_id' => '',
    'option_id'               => $option_query->row['option_id'],
    'option_value_id'         => '',
    'name'                    => $option_query->row['name'],
    'option_value'            => $option_value,
    'type'                    => $option_query->row['type'],
    'quantity'                => '',
    'subtract'                => '',
    'price'                   => '',
    'price_prefix'            => '',
    'points'                  => '',
    'points_prefix'           => '',								
    'weight'                  => '',
    'weight_prefix'           => ''
);
with:

Code: Select all

/**
 *	This modification makes the value of the option as its price
 *	we look for a text input with the name of the option "amount"
 */
if ($option_query->row['type'] == 'text' && strtolower($option_query->row['name']) == 'amount') {
    $x_price = (float) $option_value;
    $x_price_prefix = '+';
    $option_price += $x_price;
}
else {
    $x_price = '';
    $x_price_prefix = '';
}

$option_data[] = array(
    'product_option_id'       => $product_option_id,
    'product_option_value_id' => '',
    'option_id'               => $option_query->row['option_id'],
    'option_value_id'         => '',
    'name'                    => $option_query->row['name'],
    'option_value'            => $option_value,
    'type'                    => $option_query->row['type'],
    'quantity'                => '',
    'subtract'                => '',
    'price'                   => $x_price,
    'price_prefix'            => $x_price_prefix,
    'points'                  => '',
    'points_prefix'           => '',								
    'weight'                  => '',
    'weight_prefix'           => ''
);

Newbie

Posts

Joined
Wed Dec 19, 2012 5:31 am

Post by poolsand » Sun Feb 17, 2013 12:43 am

I got this working with the fixed version, however I need it to hold the decimals entered. For example if a customer enters $1.25, it will drop the $.25, I need it to move the $1.25 to the cart.
Also is there a way to for the customer to ad a custom note or description to this?
I'm using this for a service billing invoice and I need them to enter the invoice # also.
Thanks!

Newbie

Posts

Joined
Mon Jan 25, 2010 9:49 am

Post by poolsand » Mon Feb 18, 2013 9:53 am

Figured out how to allow the customer to also enter the invoice #, but no luck with the decimals. I'm really stuck on this and hope someone has an answer, it's not making sense to me because you can use decimals when using regular options, but not with this mod.

Newbie

Posts

Joined
Mon Jan 25, 2010 9:49 am

Post by poolsand » Mon Feb 18, 2013 1:02 pm

Figured out the Decimal issue you now also, if anyone needs to know how, let me know.

Newbie

Posts

Joined
Mon Jan 25, 2010 9:49 am

Post by dharma » Thu Feb 21, 2013 5:09 am

Desperately hoping someone can help me here.

I too, need a way to accept donations, and the donation mods don't work. I need them to be able to add it to the cart just like any product, but to enter the amount in they wish to donate. The reason for this, is that they will be donating to several different funds.

I am trying to do this for 1.5.5.1, and tried to follow these instructions, but am lost. For instance, I can't even find the text in the product.tpl that the download refers to.

Can anyone help walk me through the process? I would even be happy to pay!

Thanks in advance for reading this!

Newbie

Posts

Joined
Thu Feb 21, 2013 5:04 am

Post by dharma » Thu Feb 21, 2013 5:19 am

For some reason, last post didn't show....trying again.

I basically need the same thing. Am using 1.5.5.1, but am completely lost on how to add a product with a user-defined price. The donation mod doesn't work for me, as the user will need to be able to add multiple products with a user-defined price.

Can someone walk me through setting this up? I downloaded the modification, but don't even the see the text that is referenced in the product.tpl file. Am I missing something? I would be happy to pay for help if needed. I really need to get this working and am in a time crunch.

Thanks for taking the time to read this!

Newbie

Posts

Joined
Thu Feb 21, 2013 5:04 am

Post by damodaranudas » Tue Dec 17, 2013 11:43 pm

It worked like a charm for our 1.5.4.1 store, thank you!
signereign wrote:Modified the code to work with OC 1.5.4. For this to work you will have to create an option type "text" and named "amount" then add it to the product.

BACK UP FILES BEFORE YOU EDIT! alternatively, you can make this a VQMOD

EDIT BEGINS:
1. open /system/library/cart.php
3. look for elseif ($option_query->row['type'] == 'text' (this is under getProducts() function)
4. inside that if-else block replace:

Code: Select all

$option_data[] = array(
    'product_option_id'       => $product_option_id,
    'product_option_value_id' => '',
    'option_id'               => $option_query->row['option_id'],
    'option_value_id'         => '',
    'name'                    => $option_query->row['name'],
    'option_value'            => $option_value,
    'type'                    => $option_query->row['type'],
    'quantity'                => '',
    'subtract'                => '',
    'price'                   => '',
    'price_prefix'            => '',
    'points'                  => '',
    'points_prefix'           => '',								
    'weight'                  => '',
    'weight_prefix'           => ''
);
with:

Code: Select all

/**
 *	This modification makes the value of the option as its price
 *	we look for a text input with the name of the option "amount"
 */
if ($option_query->row['type'] == 'text' && strtolower($option_query->row['name']) == 'amount') {
    $x_price = (float) $option_value;
    $x_price_prefix = '+';
    $option_price += $x_price;
}
else {
    $x_price = '';
    $x_price_prefix = '';
}

$option_data[] = array(
    'product_option_id'       => $product_option_id,
    'product_option_value_id' => '',
    'option_id'               => $option_query->row['option_id'],
    'option_value_id'         => '',
    'name'                    => $option_query->row['name'],
    'option_value'            => $option_value,
    'type'                    => $option_query->row['type'],
    'quantity'                => '',
    'subtract'                => '',
    'price'                   => $x_price,
    'price_prefix'            => $x_price_prefix,
    'points'                  => '',
    'points_prefix'           => '',								
    'weight'                  => '',
    'weight_prefix'           => ''
);

User avatar
Newbie

Posts

Joined
Tue Nov 20, 2012 1:20 am
Location - Colombia

Post by garyfl » Sun Jul 03, 2016 11:40 am

hi any chance of getting this to work on 2.0.3.1 ? Looking for this and cannot seem to find anything

Newbie

Posts

Joined
Thu Mar 17, 2016 1:49 am
Who is online

Users browsing this forum: No registered users and 42 guests