Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Testing parent post status before executing CRED form

$
0
0

I have a CRED form which acts as a 'Place Order' in my own custom Cart. The CRED form is as follows;

[credform class="cred-form cred-keep-original"]
	[cred_field field="form_messages" value=""]

<div class="hidefield">
[cred_generic_field field="username" type="email" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-current-user info="email"]"
}
[/cred_generic_field]
  
[cred_generic_field field="sellername" type="email" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[parent-author-email]"
}
[/cred_generic_field]
</div>

	[cred_field field="form_submit" value="Place Order" urlparam=""]
[/credform]

The main function of this CRED forma is to send out a number of order confirmation e-mails.

To avoid more than one person ordering the same unique item, I need to test whether the item in the CART is still for sale (It is possible for multiple carts to hold the same unique item).

In order to do this, I need to check the post status of the parent post (which is the item for sale) AFTER the CRED submit button is pressed but BEFORE the CRED function is executed.

Is it possible to use the cred_form_validate API function to perform this check of the parent post status?

The function needs to work as follows;

If the parent post status is 'draft' (means the item is still for sale) then the CRED submit function is actioned.

If the parent post status is 'private' (means the item has already been purchased by someone else) then the CRED submit function is halted and an error message is displayed, e.g. 'This item has already been purchased'.

Regards

Robert


Viewing all articles
Browse latest Browse all 20145

Trending Articles