WooCommerce Integration (Paid Addon)

Posted in: Modules and Extensions

This integration allows accepting payments for Ad postings using WooCommerce. Using this addon you can configure multiple listing schemes by simply creating multiple WooCommerce products.

In order to activate it, you need to have WooCommerce plugin and WPAdverts WooCommerce Payments add-on installed. If you do not have our WC Payments add-on you can purchase a copy here.

Once you have a copy of WC Payments (this should be a zip file), you can install and activate it on your site from wp-admin / Plugins / Add New / Upload panel.

Configuration

Once enabled you can go into Module settings panel which will look pretty similar to the one on the screenshot below:

wpadverts-wc-config

The module has few options only and you actually need t fill them only if the first checkbox is checked.

  • Manage – checking this checkbox will add “My Ads” panel to the WooCommerce user panel when user will go to this panel he will basically see [adverts_manage] shortcode inside WC user panel.
  • ‘My Ads’ Panel Title – allows selecting title visible in WC user panel (by default it is ‘My Ads’).
  • ‘My Ads’ Panel Slug – allows selecting slug (part of URL) for this panel (by default it is ‘my-ads’).

Creating Listing Types

Using the WC integration basically, comes down to creating some WC Products. Go to wp-admin / Products / Add New panel, enter product Title and optionally description. Now in Product Data – Product Type dropdown select “Single Listing (WPAdverts)” or since version 1.2.0 “Renew Listing (WPAdverts)” – what is the difference?

Single Listings can be used to post new Ads usually using [adverts_add] shortcode, the Renew Listings can be used to renew existing listings. If you have at least one Renew Listing product configured then in [adverts_manage] panel users will find a “Renew Ad” button which they can use to renew their Ad.

Selecting Single Listing or Renew Listing will do two things:

  • Adverts will know that this product is a Listing Type (and will be able to display in in Post an Ad Form), and second
  • You will be able to enter Ad Duration that is how long (in days) Ad should be displayed and turn on Feature ad listing checkbox, checking it will display the ad above other listings.

wc-create-product

When you enter required data and save the product, it will display in [adverts_add] or [adverts_manage] if the product is published and visible.

Using Listing Types

Posting a New Ad – when posting and Ad users will see in Listing Information group in the [adverts_add] form, from there users will be able to select from previously created WooCommerce Products (of course only from those that have “Single Listing (WPAdverts)” selected as product type.

wpadverts-payments-add

If a user will select one of the products which price is higher than 0.00 and in preview clicks “Publish Listing” button, his product will be added to cart and user will be redirected to WooCommerce checkout page.

Renewing an Advert – in the [adverts_manage] panel after clicking the “More” button, a “Renew Ad” button will show if you have at least one Renew Listing created and published.

After clicking the Renew Ad button you will be asked to select renewal type and submit the form, if the price of renewal is greater than 0.00 user will be redirected to WooCommerce checkout page. Note that if user

Pro Tip: It is possible to have free renewals if you set product price to 0.00, however if a user will select this renewal type, then his Ad will be automatically renewed, but the expiration date will be set to Today + Duration set in product configuration, this is configured like that to avoid users abusing the free renewals. In other words, if you have a free renewal with the duration set to 7 days, then renewing multiple times will still set the expiration date to Today + 7 days.

Managing Paid Ads in wp-admin Panel

All Ads for which payments has not been finished for some reason, are displayed with “Pending Payment” state and link back to Order (as on the screenshot below), alternatively if user will not create WC order or the order will be deleted by Administrator the Ad will display with Abandoned state, which means that user cannot finish payment.

wc-pending-listing

Troubleshooting

If you wish to use WooCommerce integration make sure you have the bundled Payments Module disabled, both WC Integration and Payments Module provide basically the same functionality, so they most probably will be conflicting when enabled at the same time.

Customization

By default the WC integration will allow using only products which are visible in WooCommerce catalog or search, you can change that and show products which are hidden as well by adding the code below to your theme functions.php file

add_filter( "adext_wc_payments_products_new", "show_hidden_wpadverts_products" );
add_filter( "adext_wc_payments_products_renew", "show_hidden_wpadverts_products" );
function show_hidden_wpadverts_products( $args ) {
    $args["meta_query"][0]["value"] = array( "catalog", "search", "hidden" );
    return $args;
}

You can use the above filters to further tune which products can be used by users, the $args is basically a list of arguments that will be passed to get_posts() function.