Finder API: Products

Templates

Main Product

Namepadloper-product
DescriptionThe template used by Padloper product pages that are not variants. The pages may or may not have variants (child pages).

Fields

Below are the frontend-relevant fields in the padloper-product template.

INFO

Some of the fields listed here may not be present in depending on the Padloper optional features that were selected during install.

Title
Nametitle
DescriptionProcessWire PageTitle/PageTitleLanguage field that stores the title of the product.
SubfieldsN/A
API$product->title
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var string $product->title */
echo $product->title;
1
2
3
4
5
6
7
Description
Namepadloper_description
DescriptionTexarea/TextareaLanguage rich-text field that contains the product description.
SubfieldsN/A
API$product->padloper_description
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var string $description */
$description = $product->padloper_description;
echo $description;
1
2
3
4
5
6
7
8
Stock
Namepadloper_product_stock
DescriptionCustom Padloper field that holds stock information for a product, including sku, price, quantity and inventory control.
Subfieldssku, price, compare_price, quantity, allow_backorders, enabled.
API $product->padloper_product_stock
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var WireData $stock */
$stock = $product->padloper_product_stock;
echo $stock->sku;
echo $stock->price;
echo $stock->comparePrice;
echo $stock->quantity;
echo $stock->allowBackorders;
echo $stock->enabled;
1
2
3
4
5
6
7
8
9
10
11
12
13
Images
Namepadloper_images
DescriptionProcessWire multi-images field that stores the product images.
SubfieldsAs per ProcessWire image fields.
API $product->padloper_images

INFO

The allowed image file extensions are determined by the shop's general settings.

// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var Pageimages $images */
$images = $product->padloper_images;
// work with $images
1
2
3
4
5
6
7
8
Settings
Namepadloper_product_settings
DescriptionCustom Padloper field that holds product settings information for the details product shipping type, whether the product is taxable, if it tracks inventory, main colour and whether it will have variants.
Subfieldsshipping_type, taxable, track_inventory, use_variants, colour.
API $product->padloper_product_settings
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var WireData $settings */
$settings = $product->padloper_product_settings;
// 'physical' | 'physical_no_shipping' | 'digital' | 'service'
echo $settings->shippingType;
echo $settings->taxable;
echo $settings->trackInventory;
echo $settings->useVariants;
echo $settings->colour;
1
2
3
4
5
6
7
8
9
10
11
12
13
Attributes
Namepadloper_product_attributes
DescriptionProcessWire multi-page reference field that stores the attributes selected for this product. E.g. colour, size, material.
Subfieldstitle
API $product->padloper_product_attributes
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var PageArray $attributes */
$attributes = $product->padloper_product_attributes;
if($attributes->count()){
    foreach ($attributes as $attribute) {
        /** @var Page $attribute */
        echo $attribute->title;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Downloads
Namepadloper_downloads
DescriptionProcessWire multi-page reference field that stores the downloads selected for this product.
Subfieldstitle, padloper_description, padloper_file
API $product->padloper_downloads
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var PageArray $downloads */
$downloads = $product->padloper_downloads;
if($downloads->count()){
    foreach ($downloads as $download) {
        /** @var Page $download */
        echo $download->title;
        echo $download->padloper_description;
        /** @var Pagefile $downloadFile */
        $downloadFile = $download->padloper_file;
        echo $downloadFile->name;
        // etc
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Type
Namepadloper_type
DescriptionProcessWire single-page reference field that stores the product type this product, e.g. belt, shirt, etc.
Subfieldstitle
API $product->padloper_type
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var Page $type */
$type = $product->padloper_type;
if($type){
    echo $type->title;
}
1
2
3
4
5
6
7
8
9
10
Brand
Namepadloper_brand
DescriptionProcessWire single-page reference field that stores the product brand/manufacturer.
Subfieldstitle, padloper_images
API $product->padloper_brand
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var Page $brand */
$brand = $product->padloper_brand;
if($brand){
    echo $brand->title;
    if(!empty($brand->padloper_images->count())){
        /** @var Pageimage $logo */
        $logo = $brand->padloper_images->first();
        // work with logo
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Categories
Namepadloper_categories
DescriptionProcessWire multi-page reference field that stores the product categories, e.g. kitchen, electronics, summer wear, etc.
Subfieldstitle, padloper_description
API $product->padloper_categories
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var PageArray $categories */
$categories = $product->padloper_categories;
if($categories->count()){
    foreach ($categories as $category) {
        echo $category->title;
        echo $category->padloper_description;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Tags
Namepadloper_tags
DescriptionProcessWire multi-page reference field that stores the product tags, e.g. sale, hot, etc.
Subfieldstitle
API $product->padloper_tags
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var PageArray $tags */
$tags = $product->padloper_tags;
if($tags->count()){
    foreach ($tags as $tag) {
        echo $tag->title;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
Properties
Namepadloper_product_properties
DescriptionCustom Padloper multi-field that holds product information for product properties, i.e. the propery type (e.g. length, weight, grade, etc) , the dimension/measurement of the property (e.g. kilograms, litres, etc) and the numeric value of the dimension.
Subfieldsvalue, property_id, dimension_id
API $product->padloper_product_properties
// any valid ProcessWire selector
$selector  = "";

/** @var Page $product */
$product = $padloper->get("template=product,{$selector}");
/** @var WireArray $productProperties */
$productProperties = $product->padloper_product_properties;
if($productProperties->count()){
    foreach ($productProperties as $productProperty) {
        // e.g. Weight
        echo $productProperty->property;
        echo $productProperty->propertyID;
        // e.g. Kilograms
        echo $productProperty->dimension;
        echo $productProperty->dimensionID;
        // e.g. 25
        echo $productProperty->value;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Product Variant

Fields

Below are the frontend-relevant fields in the padloper-product-variant template.

INFO

Some of the fields listed here may not be present in depending on the Padloper optional features that were selected during install.

In the all the product variants examples, the variable $variants is populated using the method $padloper->getProductVariants()as follows:

// for selectors
// $productID = 1846;
// $productName = "t-shirt";
$productTitle = "T shirt";
// $product = $padloper->get("title={$productTitle}");

// selector can be product Page, ID, name or title
// $selector = $productID;
// $selector = $product;
// $selector = $productName;
$selector = $productTitle;
/** @var PageArray $variants */
$variants = $padloper->getProductVariants($selector, $isUseRaw = false);
// ... work with $variants
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Namepadloper-product-variant
DescriptionThe template used by Padloper product pages that are variants. The pages cannot have child pages themselves.
Title
Nametitle
DescriptionProcessWire PageTitle/PageTitleLanguage field that stores the title of a product variant.
SubfieldsN/A
API$variant->title
/** @var PageArray $variants */
if (!empty($variants)) {
	foreach ($variants as $variant) {
		echo $variant->title . '<br>';
	}
}
1
2
3
4
5
6
Stock
Namepadloper_product_stock
DescriptionCustom Padloper field that holds stock information for a product variant, including sku, price, quantity and inventory control.
Subfieldssku, price, compare_price, quantity, allow_backorders, enabled.
API $variant->padloper_product_stock
/** @var PageArray $variants */
if (!empty($variants)) {
	foreach ($variants as $variant) {
		/** @var WireData $stock */
		$stock = $variant->padloper_product_stock;
		echo $stock->sku . '<br>';
		echo $stock->price . '<br>';
		echo $stock->comparePrice . '<br>';
		echo $stock->quantity . '<br>';
		echo $stock->allowBackorders . '<br>';
		echo $stock->enabled . '<br>';
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
Images
Namepadloper_images
DescriptionProcessWire multi-images field that stores the images for a product variant.
SubfieldsAs per ProcessWire image fields.
API $variant->padloper_images

INFO

The allowed image file extensions are determined by the shop's general settings.

/** @var PageArray $variants */
if (!empty($variants)) {
	foreach ($variants as $variant) {
		/** @var Pageimages $images */
		$images = $variant->padloper_images;
		// work with $images
	}
}
1
2
3
4
5
6
7
8
Downloads
Namepadloper_downloads
DescriptionProcessWire multi-page reference field that stores the downloads selected for a product variant.
Subfieldstitle, padloper_description, padloper_file
API $variant->padloper_downloads
/** @var PageArray $variants */
if (!empty($variants)) {
	foreach ($variants as $variant) {
		echo $variant->title . " ({$padloper->renderCartPriceAndCurrency($variant->padloper_product_stock->price)}))</br>";
		/** @var PageArray $downloads */
		$downloads = $variant->padloper_downloads;
		if ($downloads->count()) {
			foreach ($downloads as $download) {
				/** @var Page $download */
				echo $download->title . '<br>';
				echo $download->padloper_description . '<br>';
				/** @var Pagefile $downloadFile */
				$downloadFile = $download->padloper_file;
				echo $downloadFile->name . '<br>';
				// etc
			}
		}
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Examples

Find multiple products

$padloper->find()

// any valid ProcessWire selector
$selector  = "";
 /** @var PageArray $products */
$products = $padloper->find("template=product,{$selector}");
// work with $products
1
2
3
4
5

OR:groups

// find products whose stock is greater than 4 or whose category is 'kitchen'
$selector = "template=product,(stock.quantity>4),(categories=kitchen)";
/** @var Page $product */
$products = $padloper->find($selector);
1
2
3
4

$padloper->findRaw()


$selector = "template=product,sort=title";
$fieldsOptions = ['title', 'padloper_product_stock' => 'stock', 'padloper_images' => 'images'];
/** @var array $products */
$products = $padloper->findRaw($selector, $fieldsOptions);
$out = '';
if (!empty($products)) {
    $out .= "<ul>";
    foreach ($products as $id => $values) {
        $title = $values['title'];
        $stock = $values['stock'];
        $price = $padloper->renderCartPriceAndCurrency($stock['price']);
        $quantity = $stock['quantity'];
        $out .=  "<li>{$title} - {$price} ({$quantity} in stock)</li>";
    }
}
echo $out;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Retrieve a single product

$padloper->get()

// get a single product
$out = "";
$selector = "template='product";
/** @var Page $product */
$product = $padloper->get($selector);
$out .= "<p>" . $product->title . "</p>";
if ($product->padloper_images->count()) {
	$image = $product->padloper_images->first();
	$imageThumb = $image->height(130);
	$out .= "<img src={$image->url}>";
}
echo $out;
1
2
3
4
5
6
7
8
9
10
11
12

$padloper->getRaw()

Get a single product's title and image thumb

$selector = "template=product,sort=-title";
$fieldsOptions = ['title', 'padloper_images' => 'images'];
/** @var array $product */
$product = $padloper->getRaw($selector, $fieldsOptions);
// work with $product
1
2
3
4
5

Find a product's variants

$padloper->getProductVariants()

$padloper->getProductVariants(mixed $product, bool $isUseRaw = true, array|null $fields = null, array $options = [])
1

Arguments

NameType(s)Description
$productstring, array, fieldThe product whose variants to retrieve.
$isUseRawboolWhether to use $pages->find() or $pages->findRaw() (default).
$fieldsstring, array, FieldThe field argument passed to $pages->findRaw().
$optionsarrayThe options argument passed to $pages->findRaw().

$productTitle = "T shirt";
// for selectors
// $productID = 1846;
// $productName = "t-shirt";
$productTitle = "T shirt";
// $product = $padloper->get("title={$productTitle}");

// selector can be product Page, ID, name or title
// $selector = $productID;
// $selector = $product;
// $selector = $productName;
$selector = $productTitle;
/** @var PageArray $variants */
$variants = $padloper->getProductVariants($selector, $isUseRaw = false);
// ... work with $variants
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16