I am trying to: issue a refund for a customer. They have 5 ad credits, but have used 1. For whatever reason in our simulation we have decided to give them a refund. The refund itself worked perfectly: hidden link
Link to a page where the issue can be seen:
However the user still sees ad credits here: hidden link
If they check their listing packages, there are no active packages, which is correct. (see hidden link)
I expect to see the ad credits to be 0, but instead they are 4. Does that mean that the shortcode [classifieds-return-available-ad-credits] can only have the full package amount deducted, instead of the remaining amount on the package?
I don't recognise your screenshots, and the [classifieds-return-available-ad-credits] shortcode is not a Toolset shortcode, certainly not one I recognise and it doesn't appear to be registered by our classifieds site, for example.
Can you tell me more about your site and how it is made?
Our version of the site turns the above Toolset reference site from strictly classifieds to property listing. I have not changed any of the packages (except for the labels, which shouldn't affect anything). All the functionality is something that comes with the reference site.
Sorry about that, I did a search on the plugin that registers the custom classifieds shortcodes to see if it was one of ours but I had a typo in my search term.
The shortcode [classifieds-return-available-ad-credits] simply outputs the number of credits for a user.
I looked through the code that handles the logic of buying ad packages and assigning credits, and there is no provision for handling refunds.
You'll need to add some code to handle this yourself.
The available credits are stored as custom user meta with a key of wpcf-user-total-available-ad-credits.
Although the reference sites are provided for training and as proof-of-concepts rather than fully-fledged solutions it would be helpful if such functionality were built-in, and I'm passing that feedback on to Agnes who is responsible for the reference sites.
Good call on passing back that feedback as your Reference Sites page says "Toolset Reference Sites are fully functional website designs that you can use as the starting point for your own website. Each of these reference sites represents a project with a specific purpose." I imagine I'm not the first. 🙂
Will this ticket remain open should I have any further questions?
OK - I've had a look through, and while I can do some custom stuff, I have two questions first.
Question 1:
With regards to the credits under the packages type... there seems to be some deduction as ads are consumed. See: hidden link
Does this affect any text on the site? If you change this value alone it doesn't seem to affect anything (hence, the point)?
Question 2:
On the My Account dashboard there is some text here: hidden link
What drives this value? (Apologies if it's obvious - I feel like I'm following loops til I'm cross-eyed here)
Hi Nigel - thanks for sticking with me on this one.
With point 1 - If I manually change the "Package number of ads allowed" to zero, then it is not reflected on the screen hidden link
With point 2 - I'm asking because on the Woocommerce page it seems to be added as well.
See the following link after I buy a package: hidden link
I've had a request if it can be removed from this page.
On the My Account screen shown in your screenshot, that section is generated by the "My Account sidebar" Content Template.
If you examine that you'll see the number of available ads is generated with the classifieds-return-available-ad-credits shortcode.
If you examine the code in the toolset-classifieds plugin you'll see that the shortcode uses the following function:
/*Function to compute available ad credits*/
public function classifieds_return_available_ad_credits($user_id = '') {
if (empty($user_id)) {
global $current_user;
//Get user_id
$user_id = $current_user->ID;
}
//Get number of ad package credits for this user
$ad_credits_available = get_user_meta($user_id, 'wpcf-user-total-available-ad-credits', TRUE);
$out = '0';
if ($ad_credits_available){
$out = $ad_credits_available;
}
return $out;
}
Note that it retrieves the number of available ads from USER meta.
When you are looking at the package in the WordPress admin, that is a post, and so the number of ad packages there is POST meta. If you change that, you are not changing the USER meta where the number of available ads is stored. (Looking in the same file there is a function which displays the same USER meta on the WooCommerce page.)
If you look in the file package_order.class.php you'll see a function classifieds_cred_submit_complete_add_another_premium_ad on line 43.
If you read through that you'll notice that when an ad is submitted it updates both the user meta and post meta.
If you are adjusting the number of available ads you'll need to do the same.