Problem:
The user was unable to display the shop page using a specific layout.
Solution:
- Make sure that the layout has an archive cell.
- Make sure that the page is not assigned a different layout.
- Make sure to have chosen WooCommerce Views template in Toolset Commerce settings.
Problem:
The user configured the products archive template to be ordered by the price but that did not work for him.
Solution:
It turns out that the price was ordered as a string instead of a number, I updated the wpv-sort-orderby to include the following argument orderby_as_numeric_for="field-views_woo_price" and it is giving correct results.
[wpv-sort-orderby type="select" options="post_date,post_title,field-views_woo_price" label_for_post_date="Newest" label_for_post_title="A to Z" label_for_field-views_woo_price="Price" orderby_as_numeric_for="field-views_woo_price" orderby_ascending_for="post_date,post_title,field-views_woo_price"]
Note, that a product does not have a price, it is considered to have a price equals to 0.
Problem: I have a Commerce Form that is used to publish a post and connect it to an Order. The Commerce Form is configured to publish the post when the Order is completed. However, sometimes clients submit the same Form multiple times for the same Order. In this case, several posts are created but only the most recent post is published when the Order is completed. I would like to publish all the posts connected to the Order when the Order is completed.
Solution: Forms Commerce is not designed to support more than one post per Order, so custom code is required to make this work. See the example here using the cred_commerce_after_order_completed API:
// publish all posts created when one commerce form is submitted mutliple times in the same order
add_action( 'cred_commerce_after_order_completed', 'publish_all_ordered_posts', 10, 1 );
function publish_all_ordered_posts( $data ) {
// which order was completed?
$order_id = $data['transaction_id'];
// which posts were created in this order?
$all_order_posts = get_post_meta( $order_id, '_cred_post_id');
// loop over all the created posts
if( !is_array( $all_order_posts ) )
return;
foreach( $all_order_posts as $all_order_post ) {
// check the post status
$this_post_status = get_post_status( $all_order_post );
// publish any unpublished posts
if ( $this_post_status != 'publish' ) {
$args = array(
'ID' => $all_order_post,
'post_status' => 'publish'
);
wp_update_post( $args );
}
}
}