forked from thinkshout/mailchimp_ecommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailchimp_ecommerce.api.php
More file actions
48 lines (41 loc) · 1.38 KB
/
mailchimp_ecommerce.api.php
File metadata and controls
48 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* @file
* Hooks provided by the Mailchimp eCommerce module.
*/
/**
* Allows modules to react to the addition of a Mailchimp store.
*
* @param object $store
* The new store.
*
* @see http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/#read-get_ecommerce_stores_store_id
*/
function hook_mailchimp_ecommerce_add_store($store) {
}
/**
* Allow other modules to alter the description of a product.
*
* @param string $description
* Current value for the product description text.
*
* @param $product
* The product being added or updated in Drupal.
*/
function hook_mailchimp_ecommerce_product_description_alter(&$description, $product) {
// Query the database to find our custom display node.
$query = new EntityFieldQuery;
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'custom_node_type')
->fieldCondition('field_custom_product', 'product_id', $product->product_id, '=')
->range(0, 1);
$result = $query->execute();
if ($result && !empty($result['node'])) {
$nids[$product->product_id] = reset($result['node']);
$node = node_load($nids[$product->product_id]);
// The description lives in a custom field called product_description.
if (!isset($node->field_product_desription)) {
$description = check_plain($node->product_description[LANGUAGE_NONE][0]['value']);
}
}
}