Compare commits
1 commit
master
...
membership
Author | SHA1 | Date | |
---|---|---|---|
![]() |
81fd5ea56e |
12 changed files with 28 additions and 17 deletions
|
@ -294,7 +294,7 @@ class CRM_Twingle_BAO_TwingleShop extends CRM_Twingle_DAO_TwingleShop {
|
|||
/**
|
||||
* Get associated products.
|
||||
*
|
||||
* @return list<CRM_Twingle_BAO_TwingleProduct>
|
||||
* @return array[Civi\Twingle\Shop\BAO\TwingleProduct]
|
||||
* @throws \Civi\Core\Exception\DBQueryException
|
||||
* @throws \Civi\Twingle\Shop\Exceptions\ProductException
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,7 @@ declare(strict_types = 1);
|
|||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Exceptions\BaseException;
|
||||
use Civi\Twingle\Shop\Exceptions\LineItemException;
|
||||
use Civi\Twingle\Shop\BAO\TwingleProduct;
|
||||
|
||||
class CRM_Twingle_Submission {
|
||||
|
||||
|
@ -502,7 +503,7 @@ class CRM_Twingle_Submission {
|
|||
// Try to find the TwingleProduct with its corresponding PriceField
|
||||
// for this product
|
||||
try {
|
||||
$price_field = CRM_Twingle_BAO_TwingleProduct::findByExternalId($product['id']);
|
||||
$price_field = TwingleProduct::findByExternalId($product['id']);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Civi::log()->error(E::LONG_NAME .
|
||||
|
|
|
@ -900,6 +900,11 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
$membership_data['source'] = $membership_source;
|
||||
}
|
||||
|
||||
// Add custom fields from mapping.
|
||||
if (isset($custom_fields['Membership'])) {
|
||||
$membership_data += $custom_fields['Membership'];
|
||||
}
|
||||
|
||||
$membership = civicrm_api3('Membership', 'create', $membership_data);
|
||||
$result_values['membership'] = $membership;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Civi\Twingle\Shop\Exceptions\ProductException;
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleProduct;
|
||||
|
||||
/**
|
||||
* TwingleProduct.Create API specification (optional)
|
||||
|
@ -120,7 +121,7 @@ function civicrm_api3_twingle_product_Create($params): array {
|
|||
|
||||
try {
|
||||
// Create TwingleProduct and load params
|
||||
$product = new CRM_Twingle_BAO_TwingleProduct();
|
||||
$product = new TwingleProduct();
|
||||
$product->load($params);
|
||||
|
||||
// Save TwingleProduct
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleProduct;
|
||||
|
||||
/**
|
||||
* TwingleProduct.Delete API specification (optional)
|
||||
|
@ -55,7 +56,7 @@ function civicrm_api3_twingle_product_Delete($params) {
|
|||
}
|
||||
|
||||
// Get TwingleProduct object
|
||||
$product = CRM_Twingle_BAO_TwingleProduct::findById($product_data['id']);
|
||||
$product = TwingleProduct::findById($product_data['id']);
|
||||
|
||||
// Delete TwingleProduct and associated PriceField and PriceFieldValue
|
||||
$result = $product->delete();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleProduct;
|
||||
|
||||
/**
|
||||
* TwingleProduct.Get API specification (optional)
|
||||
|
@ -86,7 +87,7 @@ function civicrm_api3_twingle_product_Get($params) {
|
|||
$altered_params = [];
|
||||
|
||||
// Specify product fields to define table prefix
|
||||
$productFields = array_keys(CRM_Twingle_BAO_TwingleProduct::fields());
|
||||
$productFields = array_keys(TwingleProduct::fields());
|
||||
|
||||
// Alter params (prefix with table name)
|
||||
foreach ($possible_params as $param) {
|
||||
|
@ -117,7 +118,7 @@ function civicrm_api3_twingle_product_Get($params) {
|
|||
|
||||
// Execute query
|
||||
try {
|
||||
$dao = CRM_Twingle_BAO_TwingleProduct::executeQuery($query, $query_params);
|
||||
$dao = TwingleProduct::executeQuery($query, $query_params);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
return civicrm_api3_create_error($e->getMessage(), [
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleShop;
|
||||
use Civi\Twingle\Shop\Exceptions\ShopException;
|
||||
|
||||
/**
|
||||
|
@ -61,7 +62,7 @@ function civicrm_api3_twingle_shop_Create($params) {
|
|||
|
||||
try {
|
||||
// Create TwingleShop and load params
|
||||
$shop = new CRM_Twingle_BAO_TwingleShop();
|
||||
$shop = new TwingleShop();
|
||||
$shop->load($params);
|
||||
|
||||
// Save TwingleShop
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleShop;
|
||||
|
||||
/**
|
||||
* TwingleShop.Delete API specification (optional)
|
||||
|
@ -56,10 +56,10 @@ function civicrm_api3_twingle_shop_Delete($params) {
|
|||
}
|
||||
|
||||
// Get TwingleShop object
|
||||
$shop = CRM_Twingle_BAO_TwingleShop::findById($shop_data['id']);
|
||||
$shop = TwingleShop::findById($shop_data['id']);
|
||||
|
||||
// Delete TwingleShop
|
||||
/** @var \CRM_Twingle_BAO_TwingleShop $shop */
|
||||
/* @var \Civi\Twingle\Shop\BAO\TwingleShop $shop */
|
||||
$result = $shop->deleteByConstraint();
|
||||
if ($result) {
|
||||
return civicrm_api3_create_success(1, $params, 'TwingleShop', 'Delete');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleShop;
|
||||
use Civi\Twingle\Shop\Exceptions\ApiCallError;
|
||||
use Civi\Twingle\Shop\Exceptions\ProductException;
|
||||
use Civi\Twingle\Shop\Exceptions\ShopException;
|
||||
|
@ -54,7 +55,7 @@ function civicrm_api3_twingle_shop_Fetch($params) {
|
|||
// Get products for all projects of type 'shop'
|
||||
foreach ($projectIds as $projectId) {
|
||||
try {
|
||||
$shop = CRM_Twingle_BAO_TwingleShop::findByProjectIdentifier($projectId);
|
||||
$shop = TwingleShop::findByProjectIdentifier($projectId);
|
||||
$products = $shop->fetchProducts();
|
||||
$returnValues[$projectId] = [];
|
||||
$returnValues[$projectId] += $shop->getAttributes();
|
||||
|
@ -62,7 +63,7 @@ function civicrm_api3_twingle_shop_Fetch($params) {
|
|||
return $product->getAttributes();
|
||||
}, $products);
|
||||
}
|
||||
catch (ShopException | ApiCallError | ProductException $e) {
|
||||
catch (ShopException|ApiCallError|ProductException $e) {
|
||||
// If this project identifier doesn't belong to a project of type
|
||||
// 'shop', just skip it
|
||||
if ($e->getErrorCode() == ShopException::ERROR_CODE_NOT_A_SHOP) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use Civi\Twingle\Shop\BAO\TwingleShop;
|
||||
|
||||
/**
|
||||
* TwingleShop.Get API specification (optional)
|
||||
|
@ -92,7 +92,7 @@ function civicrm_api3_twingle_shop_Get($params) {
|
|||
|
||||
// Execute query
|
||||
try {
|
||||
$dao = CRM_Twingle_BAO_TwingleShop::executeQuery($query, $query_params);
|
||||
$dao = TwingleShop::executeQuery($query, $query_params);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
return civicrm_api3_create_error($e->getMessage(), [
|
||||
|
|
2
info.xml
2
info.xml
|
@ -15,7 +15,7 @@
|
|||
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
|
||||
</urls>
|
||||
<releaseDate></releaseDate>
|
||||
<version>1.6-dev</version>
|
||||
<version>1.5-dev</version>
|
||||
<develStage>dev</develStage>
|
||||
<compatibility>
|
||||
<ver>5.58</ver>
|
||||
|
|
|
@ -17,7 +17,7 @@ function twingle_civicrm_pre($op, $objectName, $id, &$params) {
|
|||
|
||||
// Create/delete PriceField and PriceFieldValue for TwingleProduct
|
||||
elseif ($objectName == 'TwingleProduct') {
|
||||
$twingle_product = new CRM_Twingle_BAO_TwingleProduct();
|
||||
$twingle_product = new \Civi\Twingle\Shop\BAO\TwingleProduct();
|
||||
$twingle_product->load($params);
|
||||
if ($op == 'create' || $op == 'edit') {
|
||||
$twingle_product->createPriceField();
|
||||
|
@ -30,7 +30,7 @@ function twingle_civicrm_pre($op, $objectName, $id, &$params) {
|
|||
|
||||
// Create PriceSet for TwingleShop
|
||||
elseif ($objectName == 'TwingleShop' && ($op == 'create' || $op == 'edit')) {
|
||||
$twingle_shop = new CRM_Twingle_BAO_TwingleShop();
|
||||
$twingle_shop = new \Civi\Twingle\Shop\BAO\TwingleShop();
|
||||
$twingle_shop->load($params);
|
||||
$twingle_shop->createPriceSet();
|
||||
$params = $twingle_shop->getAttributes();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue