Plugin Author
myCred
(@designbymerovingi)
Hi.
First off, I am really sorry about your account on the myCRED website.
The site got bombarded with spam registrations and in my “clean up” I might have removed a few innocent accounts.
If you register again Ill make sure you regain the points you lost re-assign your post.
As I previously asked, how do you wan to sell these updates? You want to use a store or sell via users profiles?
Hi,
I want to sell via users profiles.
If use the store, I want to use WooCoomerce.
Thank you!
Plugin Author
myCred
(@designbymerovingi)
Ok.
The first thing we need to do is to create a product in WooCommerce for the “Upgrade”. You can create a product for each Mb package for example, so users can buy 10Mb space, 100 Mb space or 200 Mb space as an example.
Next, for each project we set a custom field that we will call something unique like “disk-space”. This custom field will hold the amount of space a user buys.
Next we will need to hook into the myCRED Payment Gateway in WooCommerce and adjust the users site balance according to the product they purchased.
We basically will loop though the order and check each product to see if they have the “disk-space” custom field. If they do, we add up the amount of space they purchased and adjust the site settings.
Now, before we get to the code, I need to mention a few things:
1. You will need to limit the store yourself to only allow site admins to purchase disk space. The example given here will allow anyone in the sites store to buy upgrades.
2. You could optionally also use a Virtual Product with variations but this is a bit more tricky and complicated.
3. You will need to setup the store on each site where purchases goes to that sites space. If you want to use a central store on your main site, you will need to adjust the code to also include which site the change should apply to. Either if the user selects the site or you collect that information based on the buyer.
Ok so I have put together the code for you here. Copy the entire code and paste it into your themes functions.php file. Make sure the Gateway add-on is enabled on the myCRED > Add-ons page.
Dear Gabriel.
Thank you for writing code.
That code is fantastic!!
I have a question.
Do not need to switch user’s blog id?
ex)
switch_to_blog( $user_blog_id );
// Save this sites upload space setting.
update_option( ‘blog_upload_space’, $new );
restore_current_blog();
and, myCRED Add-ons Defalt Gateway is error happen.
Undefined variable: currency_symbol in /wp-content/plugins/mycred/addons/gateway/carts/mycred-woocommerce.php on line 427 Warning: array_unique() expects parameter 1 to be array, null given in /wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 209 Warning: Invalid argument supplied for foreach() in /wp-content/plugins/woocommerce/includes/admin/settings/class-wc-settings-general.php on line 46
WooCommerce 2.0.20 and 2.1.7
myCRED1.4.1
Best regards.
Plugin Author
myCred
(@designbymerovingi)
Hi.
The error message you refer to has been fixed and will be included in 1.4.2 You can already now fix it by either:
A. Download a fresh copy from the wordpress.org site and replace your current version or
B. Open the mentioned file mycred-woocommerce.php and on line 427 change:
$currency_symbol
to:
$currencies
There is no need to switch blogs. All users on your website have a unique User ID and this ID is all that matters.