Products Prices And Content

Product Post Type

AweCommerce registers a public product post type:

post_type: awc_product
slug: products
taxonomy: awc_product_category

The post type supports:

  • Title.
  • Editor.
  • Excerpt.
  • Thumbnail.
  • Revisions.
  • Page attributes.
  • Custom fields.

Query Product Posts

$query = new WP_Query([
    'post_type' => 'awc_product',
    'post_status' => 'publish',
    'posts_per_page' => 12,
]);

while ($query->have_posts()) {
    $query->the_post();

    printf(
        '<a href="%s">%s</a>',
        esc_url(get_permalink()),
        esc_html(get_the_title())
    );
}

wp_reset_postdata();

Query Product Categories

$terms = get_terms([
    'taxonomy' => 'awc_product_category',
    'hide_empty' => true,
]);

foreach ($terms as $term) {
    echo esc_html($term->name);
}

Product Types

Product types:

virtual
downloadable
service
membership
software

Software kinds:

wordpress_plugin
wordpress_theme
wordpress_bundle

Price Concepts

Prices store:

  • Product ID.
  • Name.
  • Slug.
  • Amount in minor units.
  • Currency.
  • Active state.
  • Checkout visibility.
  • Billing interval.
  • Billing interval count.
  • Setup fee.
  • Trial days.
  • Trial payment-method requirement.
  • Billing cycle limit.
  • Metadata.

Use integers for money:

$amount_minor = 9900; // USD 99.00

Do not use floats for money calculations.

Product Helper Functions

$all = awecommerce_all_memberships(true);
$memberships = awecommerce_user_memberships(get_current_user_id());
$has = awecommerce_user_has_membership(get_current_user_id(), 123);

Protect Template Output

if (function_exists('awecommerce_user_has_membership') && awecommerce_user_has_membership(get_current_user_id(), 123)) {
    echo '<div class="member-resource">Member resource here.</div>';
} else {
    echo '<p>Please purchase a membership to access this resource.</p>';
}

Was this documentation helpful?