Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesarockstar1985/46ae88aad66bb08f4b40448c7da03294 to your computer and use it in GitHub Desktop.
Save cesarockstar1985/46ae88aad66bb08f4b40448c7da03294 to your computer and use it in GitHub Desktop.
<?php
/**
* @var \App\View\AppView $this
*/
if (isset($cmsPage) && !empty($cmsPage->jsonld)) {
$ldJson = json_decode($cmsPage->jsonld, true);
} elseif (!empty($bondType)) {
$ldJson = [
"@context" => "https://schema.org/",
"@type" => "Product",
"name" => $bondType->slug,
"description" => $bondType->display_name_state . ($bondType->description ? ': ' . $bondType->description : ''),
"brand" => [
"@type" => "Thing",
"name" => "Surety Bond"
]
];
if ($bondType->instant) {
$ldJson["offers"] = [
"@type" => "AggregateOffer",
"lowPrice" => \CakeDC\Accounting\Utility\MoneyUtil::float($bondType->low_price),
"highPrice" => \CakeDC\Accounting\Utility\MoneyUtil::float($bondType->high_price),
"priceCurrency" => "USD"
];
}
}
?>
<?php if (!empty($ldJson)) : ?>
<?= $this->Html->scriptBlock(json_encode($ldJson), ['type' => 'application/ld+json']) ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment