Measurement Protocol refund data - google-analytics

I've resolved all issues with sending data, but receive issue when trying to refund.
I've sent this array to measurement protocol :
'v' => '1',
'tid' => $tid,
'cid' => $cid,
'ti' => '12345', // this transaction exist in google
't' => 'event',
'ec'=> 'Ecommerce',
'ea'=> 'Refund',
'ni'=> '1',
'pa'=> 'refund'
But without any result. So my question is what's wrong? Maybe I need some additional call to measurement system, please advice.
BTW Google hit debugger return 'valid'.

For full refund you need to send the following
'v'='1',
't'='pageview',
'tid'='UA-3333333-8',
'cid'='382537459.1455511043',
'pa'='refund',
'ti'='000000038',
'dp'='admin/order/refund'
for partial refund you need to send
'v'='1',
't'='pageview',
'tid'='UA-3333333-8',
'cid'='382537459.1455511043',
'pa'='refund',
'ti'='000000038',
'dp'='admin/order/refund',
'pr1id' => '24-WB04',
'pr1qt' => 1
Hope it helps!

I've resolve it in this way :
I've sent new transaction with negative val
'v' => '1',
'tid' => $tid,
'cid' => $cid,
'ti' => $order,
't' => 'transaction',
'tr' => '-'.$order_total
Then send event with negative value
'v' => '1',
'tid' => $tid,
'cid' => $cid,
'ti' => $order,
't' => 'item',
'in' => $product['name'],
'ip' => '-'.$order_total,
'ic' => $products['sku'],
'iq' => -1
And it works, transactions disappear from google reports, btw also want to note that I switch script to use GET ( https://www.google-analytics.com/collect?payload_data& ) instead of POST.

Related

WordPress Custom Email Trigger

I'm using Crocoblocks/JetReviews to add reviews to my site (on a custom post type).
I can see there is a setting to require admin approval for it to be published, but I want to trigger an email to one of the admins when a review is submitted, and I don't see any settings for that so I'll have to do it myself.
I think I can handle the function to send the email, but can't sort out what to hook into or trigger it against?
Using something like this:
if ( function_exists( 'notification' ) ) :
notification( [
'title' => 'Admin Notification for Review Approval', // For internal reference.
'trigger' => 'trigger_slug', // Trigger slug (can be a Triggerable object).
'carriers' => [ // An array with format: carrier_slug => data array
'email' => [
'activated' => true, // Must be true.
'enabled' => true, // Must be true.
'subject' => 'A New Review Needs Approval',
'body' => 'There is a new review awaiting your approval.',
'recipients' => [
[
'type' => 'administrator',
'recipient' => 'admin#adminemail.com',
],
],
],
],
'enabled' => true, // Must be true.
] );
endif;
But right now that's not connected to any action...and that's where I'm lost.
Any thoughts of where to look? I couldn't figure it out from their docs so hoping someone here might have an idea of where to start at least.
Thanks!
Chad

Sonata Admin datetime picker returns wrong time

I'm new in Symfony, so excuse my ignorance.
I try to edit date and time of some event using Sonata Admin and 'sonata_type_datetime_picker' field type.
But sonata_type_datetime_picker return wrong time. It gives time for an hour less.
Here's a filled form field screenshot (time is 10:00):
Here's dump of form field value (time is 09:00):
Here's form field options:
->add('datebegin', 'sonata_type_datetime_picker', array(
'format' => 'dd.MM.yyyy HH:mm',
'label' => 'Event begins at...',
'dp_use_current' => false,
'model_timezone' => 'Europe/Moscow'
))
I'd like to note that this error exists only on the server. On my local machine everything is ok.
What could it be?
Thanks a lot in advance!
I've got this problem too. I think that you need to upgrade the software on your server (packet: tzdata etc).
See: https://en.wikipedia.org/wiki/Moscow_Time
If this doesn't help you, you can use this hack:
'view_timezone' => 'Europe/Minsk'
See:
https://en.wikipedia.org/wiki/Time_zone
https://en.wikipedia.org/wiki/UTC%2B03:00
https://en.wikipedia.org/wiki/Minsk (UTC+3)
For example:
->add('endTimestamp', 'sonata_type_datetime_picker', array(
'widget' => 'single_text',
'label' => 'sip_event_end_timestamp',
'dp_side_by_side' => true,
'dp_use_seconds' => false,
'model_timezone' => 'Europe/Moscow',
'view_timezone' => 'Europe/Minsk',
'format' => 'dd.MM.yyyy HH:mm'
)
)

EchoSign Embedd Widget with multiple signers

I want to embedd a widget in my application and be able to add 2 signers(recepients) to it without the sender required to sign the document.
The EchoSign docuemtation says that
"In the case of a reusable document that needs to be signed by multiple people, it is more efficient to call createEmbeddedWidget once and then call personalizeEmbeddedWidget for each signer."
I've tried this method but when I call the personalizeEmbeddedWidget function second time, it replaces the first recepient with the latest one instead of adding a new.
code:
$r = $s->createEmbeddedWidget(array(
'apiKey'=>ApiKey,
'widgetInfo'=>array(
'name'=>'Contract',
'fileInfos' => array(
'FileInfo' => array(
array(
'file' => $file2,
'fileName' => $filename2,
'mimeType' => 'text/html',
),
)
),
'widgetCompletionInfo'=>array(
'url'=> return-to-url,
'deframe'=> true,
),
'signatureFlow'=>'SENDER_SIGNATURE_NOT_REQUIRED',
)
));
if($r->embeddedWidgetCreationResult->success == 1){
$widgetCreationScript = $r->embeddedWidgetCreationResult->javascript;
$re = $s->personalizeEmbeddedWidget(array(
'apiKey'=>$ApiKey,
'widgetJavascript' => $widgetCreationScript,
'personalizationInfo' => array(
'email' => 1st_email_address,
)
));
$widgetScript = $re->embeddedWidgetCreationResult->javascript;
$docKey = $r->embeddedWidgetCreationResult->documentKey;
$re1 = $s->personalizeEmbeddedWidget(array(
'apiKey'=>$ApiKey,
'widgetJavascript' => $widgetScript,
'personalizationInfo' => array(
'email' => 2nd_email_address,
)
)); }
The version19 release provides a solution to this problem by adding the ability to add "counter signers" to a widget.
After the first signer completes the widget, the subsequent signer(s) get an email when it is their turn to sign.
But you can't have 2 signers sign a specific contract at the same time using the same link/screen.

Drupal Block not showing on the page

$blocks['onemore'] = array(
'info' => t('onemore'),
'status' => TRUE,
'region' => 'content',
'weight' => 0,
'cache' => DRUPAL_NO_CACHE,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => 'admin/structure/nodequeue/1/view/1',
);
Problem - The above block shows up and works perfectly and as expected at 'admin/structure/nodequeue/1/view/1'
My problem is that I need to declare dynamic amounts of blocks based on the users inputs. So I wrote a db fetch and for each loop.
If I do this then the block shows up in 'admin/modules' but the it is not in 'content' region for the seven theme. As I want to show it there.
I have double checked the values and even the admin/structure/block/manage/xdmp/onemore/configure has the value but the region is not selected.
I am assuming there is some conflict in the for each loop or the db query. Please advice your thoughts on it.
function xdmp_block_info() {
$blocks = array();
// Here we are going to do a db query so that I can get a list of
// block ids to declare
$resultxdmp = db_query("
SELECT * FROM xdmp_container_list ");
foreach($resultxdmp as $resultRecords)
{
$xdmp_nodeque_id_to_display =(int)$resultRecords->xdmp_nodequeue_id;
$xdmp_nodeque_id_to_display = intval($xdmp_nodeque_id_to_display);
$xdmp_path_to_show_block = 'admin/structure/nodequeue/'.$xdmp_nodeque_id_to_display.'
/view/'.$xdmp_nodeque_id_to_display.'';
$xdmp_machinenameofblock=(string)$resultRecords->xdmp_container_machine_name;
$xdmp_nameofblock=(string)$resultRecords->xdmp_container_name;
$blocks[$xdmp_machinenameofblock] = array(
'info' => t($xdmp_nameofblock),
'status' => TRUE,
'region' => 'content',
'weight' => 0,
'cache' => DRUPAL_NO_CACHE,
'visibility' => BLOCK_VISIBILITY_LISTED,
'pages' => $xdmp_path_to_show_block,
);
} // end for for each
return $blocks;
}
cheers,
Vishal
Are you sure the 'content' region is valid? If it's not, it of course can't show up :)

Please Explain Drupal schema and drupal_write_record

1) Where is the best place to populate a new database table when a module is first installed, enabled? I need to go and get some data from an external source and want to do it transparently when the user installs/enables my custom module.
I create the schema in {mymodule}_schema(), do drupal_install_schema({tablename}); in hook_install. Then I try to populate the table in hook_enable using drupal_write_record.
I confirmed the table was created, I get no errors when hook_enable executes, but when I query the new table, I get no rows back--it's empty.
Here's one variation of the code I've tried:
/**
* Implementation of hook_schema()
*/
function ncbi_subsites_schema() {
// we know it's MYSQL, so no need to check
$schema['ncbi_subsites_sites'] = array(
'description' => 'The base table for subsites',
'fields' => array(
'site_id' => array(
'description' => 'Primary id for site',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
), // end site_id
'title' => array(
'description' => 'The title of the subsite',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
), //end title field
'url' => array(
'description' => 'The URL of the subsite in Production',
'type' => 'varchar',
'length' => 255,
'default' => '',
), //end url field
), //end fields
'unique keys' => array(
'site_id'=> array('site_id'),
'title' => array('title'),
), //end unique keys
'primary_key' => array('site_id'),
); // end schema
return $schema;
}
Here's hook_install:
function ncbi_subsites_install() {
drupal_install_schema('ncbi_subsites');
}
Here's hook_enable:
function ncbi_subsites_enable() {
drupal_get_schema('ncbi_subsites_site');
// my helper function to get data for table (not shown)
$subsites = ncbi_subsites_get_subsites();
foreach( $subsites as $name=>$attrs ) {
$record = new stdClass();
$record->title = $name;
$record->url = $attrs['homepage'];
drupal_write_record( 'ncbi_subsites_sites', $record );
}
}
Can someone tell me what I'm missing?
If ncbi_subsites_get_subsites() is not in the .install file, you need to include whatever file its in with your module. Otherwise, it's returning nothing, in which case try dumping $subsites and exiting.
I think the answer is that drupal_write_record is not meant for install or enable hooks. I think when enabling or installing, you have to write SQL. That is the impression I am getting from reading some posts that mention that the schema is not available in these hooks.
First of all (assuming Drupal 6), drupal_write_record() cannot be called from hook_install() because Drupal would not find the database schema defined from the module, which is still going to be installed, and enabled.
Instead you need to use db_query() function. (the comments are speaking of a way to include default data by prviding it to hook_schema() serialized, but i've found no documentation on this.)
However, would you be using (the development version of) Drupal 7, you want to look at the db_insert() function instead.

Resources