Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief View product
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Nexus
* @since 29 Apr 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\modules\front\store;
@@ -200,6 +199,50 @@ class _product extends \IPS\Content\Controller
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->package( $package, $item, $this->_getForm( $package, $inCart, TRUE ), array_sum( $inCart ), $shippingMethods, $itemDataForShipping, $locationType, $renewalTerm );
}
$price = $package->price();
\IPS\Output::i()->jsonLd['package'] = array(
'@context' => "http://schema.org",
'@type' => "Product",
'name' => $package->_title,
'description' => strip_tags( $item->truncated() ),
'category' => $item->container()->_title,
'url' => (string) $package->url(),
'sku' => $package->id,
'offers' => array(
'@type' => 'Offer',
'availability' => ( $package->stock > 0 OR $package->stock == -1 ) ? 'http://schema.org/InStock' : 'http://schema.org/OutOfStock',
'price' => $price->amountAsString(),
'priceCurrency' => $price->currency,
'seller' => array(
'@type' => 'Organization',
'name' => \IPS\Settings::i()->board_name
),
),
);
if( $package->image )
{
\IPS\Output::i()->jsonLd['package']['image'] = (string) $package->image;
}
if( $package->reviewable )
{
\IPS\Output::i()->jsonLd['package']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $item->averageReviewRating(),
'ratingCount' => $item->reviews
);
}
if( isset( $length ) )
{
\IPS\Output::i()->jsonLd['package']['depth'] = array( '@type' => 'Distance', 'name' => $length->string() );
\IPS\Output::i()->jsonLd['package']['width'] = array( '@type' => 'Distance', 'name' => $width->string() );
\IPS\Output::i()->jsonLd['package']['height'] = array( '@type' => 'Distance', 'name' => $height->string() );
\IPS\Output::i()->jsonLd['package']['weight'] = array( '@type' => 'QuantitativeValue', 'name' => $weight->string() );
}
}
}
@@ -263,9 +306,9 @@ class _product extends \IPS\Content\Controller
{
$customFields = \IPS\nexus\Package\CustomField::roots();
$stickyFields = array();
foreach ( $item->details as $j => $v )
foreach ( $item->details as $k => $v )
{
if ( $v and isset( $customFields[ $j ] ) and $customFields[ $j ]->sticky )
if ( $v and isset( $customFields[ $k ] ) and $customFields[ $k ]->sticky )
{
$stickyFields[] = $v;
}
@@ -302,35 +345,55 @@ class _product extends \IPS\Content\Controller
$renewOptions = $package->renew_options ? json_decode( $package->renew_options, TRUE ) : array();
if ( count( $renewOptions ) > 1 )
{
$options = array();
$sortedRenewOptions = array();
foreach ( $renewOptions as $k => $option )
{
if ( isset( $option['cost'][ $memberCurrency ] ) )
if ( isset( $renewOptions[ $k ]['cost'][ $memberCurrency ] ) )
{
switch ( $option['unit'] )
$sortedRenewOptions[ $k ] = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $option['cost'][ $memberCurrency ]['amount'], $memberCurrency ), new \DateInterval( 'P' . $option['term'] . mb_strtoupper( $option['unit'] ) ), $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL, $option['add'], $package->grace_period ? new \DateInterval( 'P' . $package->grace_period . 'D' ) : NULL );
}
}
uasort( $sortedRenewOptions, function( $a, $b ) {
return $a->days() - $b->days();
} );
$options = array();
$first = NULL;
foreach ( $sortedRenewOptions as $k => $term )
{
$saving = NULL;
if ( \IPS\Settings::i()->nexus_show_renew_option_savings != 'none' )
{
if ( $first === NULL )
{
case 'd':
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_days', FALSE, array( 'pluralize' => array( $option['term'] ) ) );
break;
case 'm':
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_months', FALSE, array( 'pluralize' => array( $option['term'] ) ) );
break;
case 'y':
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_years', FALSE, array( 'pluralize' => array( $option['term'] ) ) );
break;
$first = $term;
}
$options[ $k ] =
\IPS\Member::loggedIn()->language()->addToStack( 'renew_option', FALSE, array( 'sprintf' => array(
(string) new \IPS\nexus\Money( $option['cost'][ $memberCurrency ]['amount'], $memberCurrency ),
$term
) ) );
else
{
$saving = $term->diff( $first, \IPS\Settings::i()->nexus_show_renew_option_savings == 'percent' );
}
}
if ( $saving and ( ( \IPS\Settings::i()->nexus_show_renew_option_savings == 'percent' and $saving->isGreaterThanZero() ) or ( \IPS\Settings::i()->nexus_show_renew_option_savings == 'amount' and $saving->amount->isGreaterThanZero() ) ) )
{
if ( \IPS\Settings::i()->nexus_show_renew_option_savings == 'percent' )
{
$options[ $k ] = \IPS\Member::loggedIn()->language()->addToStack( 'renewal_amount_with_pc_saving', FALSE, array( 'sprintf' => array( $term->toDisplay(), $saving->round(1) ) ) );
}
else
{
$options[ $k ] = \IPS\Member::loggedIn()->language()->addToStack( 'renewal_amount_with_cost_saving', FALSE, array( 'sprintf' => array( $term->toDisplay(), $saving ) ) );
}
}
else
{
$options[ $k ] = $term->toDisplay();
}
}
$form->add( new \IPS\Helpers\Form\Radio( 'renewal_term', NULL, TRUE, array( 'options' => $options ) ) );
}
/* Custom Fields */
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( array( 'cf_purchase=1' ), array( \IPS\Db::i()->findInSet( 'cf_packages', array( $package->id ) ) ) ) );
foreach ( $customFields as $field )
@@ -461,7 +524,7 @@ class _product extends \IPS\Content\Controller
}
else
{
$return['price'] = \IPS\Theme::i()->getTemplate( 'store', 'nexus' )->price( $data['price'], FALSE );
$return['price'] = \IPS\Theme::i()->getTemplate( 'store', 'nexus' )->price( $data['price'], FALSE, FALSE );
}
\IPS\Output::i()->json( $return );
}
@@ -475,7 +538,7 @@ class _product extends \IPS\Content\Controller
{
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( $additionalPage );
\IPS\Output::i()->json( array( 'dialog' => $additionalPage ) );
}
else
{