start to show mailshots related to transaction

master
Marek Isalski 9 years ago
parent 285672453a
commit e386754095

@ -84,6 +84,12 @@ function fulcrm_shoppingcart_theme( $existing, $type, $theme, $path ) {
'fulcrm_shoppingcart_transaction_item' => array( 'variables' => array( 'item' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_item',
),
'fulcrm_shoppingcart_transaction_mailshots' => array( 'variables' => array( 'transaction' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_mailshots',
),
'fulcrm_shoppingcart_transaction_mailshot' => array( 'variables' => array( 'mailshot' => null ), // data returned from fulcrm API
'template' => 'fulcrm_shoppingcart_transaction_mailshot',
),
);
}
@ -414,12 +420,12 @@ function fulcrm_shoppingcart_checkout() {
$transaction_data2 = fulcrm_apiv2_PATCH( $transaction_data[ 'data' ][ 'url' ],
$transaction_push, $query = array( 'expand' => implode( ',', array( 'd',
'lineitems',
'lineitems.d',
'lineitems.content_object',
// 'lineitems',
// 'lineitems.d',
// 'lineitems.content_object',
// XXX 'lineitems.content_object.d',
'paymentitems',
'paymentitems.d',
// 'paymentitems',
// 'paymentitems.d',
) ) ) );
if ( $transaction_data2[ 'success' ] ) {
return theme( 'fulcrm_shoppingcart_transaction_checkout', array( 'transaction' => $transaction_data2[ 'data' ] ) );
@ -432,9 +438,36 @@ function fulcrm_shoppingcart_checkout() {
}
function fulcrm_shoppingcart_checkout_success( $transaction_id, $hmac ) {
return 'success';
if ( fulcrm_crypto_check_object_id_hmac( 'transaction', $transaction_id, $hmac ) ) {
$transaction_data = fulcrm_apiv2_GET( 'transaction/' . $transaction_id . '/', $query = array( 'expand' => implode( ',', array( 'd',
'lineitems',
'lineitems.d',
'lineitems.content_object',
'mailshots',
'mailshots.campaign',
'paymentitems',
'paymentitems.d',
) ) ) );
if ( $transaction_data[ 'success' ] ) {
if ( $transaction_data[ 'data' ][ 'completed' ] )
drupal_set_message( t('Thank you for your order.'), 'status' );
$rval = '';
if ( $transaction_data[ 'data' ][ 'mailshots' ] )
$rval .= theme( 'fulcrm_shoppingcart_transaction_mailshots', array( 'transaction' => $transaction_data[ 'data' ] ) );
$rval .= '<pre>' . print_r( $transaction_data[ 'data' ], 1 ) . '</pre>'; // XXX debug
return $rval;
} else {
drupal_set_message( t('Although your transaction appears to have completed successfully, there has been a problem fetching the full transaction data.'), 'error' );
}
}
}
function fulcrm_shoppingcart_checkout_failure( $transaction_id, $hmac ) {
if ( fulcrm_crypto_check_object_id_hmac( 'transaction', $transaction_id, $hmac ) ) {
return 'failure';
}
}

@ -0,0 +1,11 @@
<li class="list-group-item"><?php print check_plain( $mailshot['campaign']['name'] ); ?>
<small><?php
$tz = new DateTimeZone('UTC');
$completed = DateTime::createFromFormat('Y-m-d\TH:i:s.u\Z',$mailshot['completed'],$timezone=$tz);
if ( $completed )
print $completed->format( '\s\e\n\t \o\n j/M/Y \a\t ga' );
?></small>
<?php foreach ( $mailshot['_view_urls']['text/html'] as $k => $v ): ?>
<a href="<?php print check_plain($v); ?>" target="_blank">view</a>
<?php endforeach; ?>
</li>

@ -0,0 +1,8 @@
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title">Emails about your Transaction</h3></div>
<ul class="list-group">
<?php foreach ( $transaction[ 'mailshots' ] as $mailshot ): ?>
<?php print theme( 'fulcrm_shoppingcart_transaction_mailshot', array( 'mailshot' => $mailshot ) ); ?>
<?php endforeach; ?>
</ul>
</div>
Loading…
Cancel
Save