Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi, Can we set min & max donation amount on Per Product (campaign) Basis ? #9

Closed
procontentxyz opened this issue Jan 24, 2022 · 8 comments

Comments

@procontentxyz
Copy link

procontentxyz commented Jan 24, 2022

I have a use case, Where I need to set min & max donation amount per product (campaign) basis.

Currently your software provide it using global setting.

kindly address my use case.

@procontentxyz procontentxyz changed the title Hi, Can we set min & max donation amount on Per Product Basis Hi, Can we set min & max donation amount on Per Product Basis ? Jan 24, 2022
@procontentxyz procontentxyz changed the title Hi, Can we set min & max donation amount on Per Product Basis ? Hi, Can we set min & max donation amount on Per Product (campaign) Basis ? Jan 24, 2022
@jonas-hoebenreich
Copy link
Owner

This feature is not currently provided. With the filter woocommerce_add_cart_item_data you can implement it yourself relatively easily. Just make sure to set the meta key 'wcdp_donation_amount' to your desired amount.
Best, Jonas

@procontentxyz
Copy link
Author

procontentxyz commented Jan 24, 2022

Suppose I have two products product A and product B,

I want to limit minimum donation amount to 100 in product A,

And minimum donation amount 300 in product B.

How can I do this using your filters that you have provided me in last answer can you guide please

Any tutorial or documentation page for this

@jonas-hoebenreich
Copy link
Owner

I'm a bit busy at the moment, so I can't write any individual code for you for the time being. What exactly are you failing at with the filter? (programming in php, how filter work, which values have to be set etc.)

@procontentxyz
Copy link
Author

i have a 5 products on my site.

i have set minimum donation amount to be: 200 for : 3 of 5 products.

i want to set minimum donation amount to be 500 for remaining 2 products.

how to set minimum OR maximum donation amount per product basis, not globally.

pelase guide big brother.

@jonas-hoebenreich
Copy link
Owner

Haven't tried it, but based on this it shouldn't be too hard to implement it:

//filter cart item data, this data is used to update the product price later
add_filter( 'woocommerce_add_cart_item_data', function($cart_item_data, $product_id, $variation_id, $quantity) {
  if ($product_id == 123 && $cart_item_data['wcdp_donation_amount'] < 200) {
  //update amount
    $cart_item_data['wcdp_donation_amount'] = 200;
  }
  return cart_item_data;
}, 10, 4 );

@procontentxyz
Copy link
Author

procontentxyz commented Jan 31, 2022

Could i set 'wcdp_donation_amount' meta using custom fields in product edit page?

Would it effect/override global setting?

@jonas-hoebenreich
Copy link
Owner

I have a feeling that you have never bothered to try to understand what the filter is doing.
There is no product metadata stored here, but meta data from the Cart object.

The plugin checks if the specified donation amount is within the min/max range and stores it in the cart meta data. You can use the filter to alter the amount.

@procontentxyz
Copy link
Author

Okk... Actually i am not a developer, i just try things

If its come as per need, i feel good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants