Table des matières
- Selling Pay-Per-Download Products - Vendre des produits à télécharger (dématérialisés)
- The buyer experience -- L'expérience client
- Setting up the product and permission structure -- Mise en oeuvre du produit et des permissions
- Payment process -- Processus de paiement
- Extension: Assigning permissions upon purchase part 1 -- Extension: assignation des droits à l'achat (partie 1)
- Pay-per-download extension part 2 -- Extension Pay-per-download (partie 2)
- Confirmation e-mails and pages -- Mails et pages de confirmation
- Extra considerations -- Considérations complémentaires
- Paypal Sandbox : comptes de test et devises
- Modification pour eZ Publish 4.3+
Confirmation e-mails and pages -- Mails et pages de confirmation
Date de publication: le vendredi 28 janvier 2011 à 00h52
Dernière modification: par Pascal BOYER le mardi 29 mars 2011 à 16h17
Versions: 4.x
We tested that our role assignment works by having our "Test User" account purchase a product and manually access the path to the download file node from the media library. However, this is not a reasonable use case. At the very least, we'd want to give the buyer links to download their purchases. And to be more user friendly, the links should lead directly to the downloadable file – not to an intermediary page.
Nous venons de tester le bon fonctionnement de l'assignation du rôle en achetant un produit par le biais du compte Utilisateur De test et en accédant manuellement au fichier à télécharger placé dans la médiathèque. Cela ne constitue cependant pas un cas d'usage acceptable. Au moins aimerions-nous fournir à l'acheteur les liens de téléchargement des articles achetés. Et pour être encore plus convivial les liens devraient permettre le téléchargement direct des fichiers - sans passer par une page intermédiaire.
Note: In this section, we will discuss modifying certain templates. However, when modifying any existing templates (from, for example, the Website Interface design or the standard design), it is best practice to create your own design extension containing copies that take precedence over the original templates.
Note: nous allons aborder, dans cet article, la modification de certains templates. Cependant, lorsque l'on modifie des templates existants (liés au design de l'interface Website ou du design standard) les bonnes pratiques vous recommandent de créer votre extension design personnelle contenant une copie des templates originaux qui prévaudront sur ces derniers.
Confirmation e-mail template / Template du mail de confirmation
When a buyer has completed the checkout process, eZ Publish will e-mail the order details to the buyer and to the site administrator. Within this e-mail is an itemized list of purchases:
Lorsqu'un acheteur termine le processus de commande, eZ Publish envoie la facture détaillée par mail à l'acheteur et à l'administrateur. Ce mail contient la liste des produits achetés:
Product items 1x eZ Publish Advanced Content Management $15.00: $15.00 Subtotal of items: $15.00
Beneath each downloadable item, we will add a download link. The order e-mail template in question is located at design/base/templates/shop/orderemail.tpl. We will copy this file to our design extension in order to edit it. Currently, the code to loop through each purchase is as follows:
Nous allons ajouter, sous chaque article téléchargeable, un lien de téléchargement. Le template d'envoi de la facture se situe dans design/base/templates/shop/orderemail.tpl. Nous copierons ce fichier dans notre extension design personnelle avant de l'éditer. Actuellement, le code boucle (liste) chaque produits acheté comme suit:
{section name=ProductItem loop=$order.product_items show=$order.product_items sequence=array(bglight,bgdark)} {$ProductItem:item.item_count}x {$ProductItem:item.object_name} {$ProductItem:item.price_inc_vat|l10n( 'currency', $locale, $symbol )}: {$ProductItem:item.total_price_inc_vat|l10n( 'currency', $locale, $symbol )} {/section}
We will replace this code with this:
Nous remplacerons ce code par celui-ci:
{foreach $order.product_items as $item} {$item.item_count}x {$item.object_name} {$item.price_inc_vat|l10n( 'currency', $locale, $symbol )}: {$item.total_price_inc_vat|l10n( 'currency', $locale, $symbol )} {def $download_classes = ezini('PayPerDownloadSettings', 'ContentClasses', 'payperdownload.ini')} {if $download_classes|contains($item.item_object.contentobject.class_identifier)} {def $download_attributes = ezini('PayPerDownloadSettings', 'Attributes', 'payperdownload.ini')} {def $download_attribute = $download_attributes[$item.item_object.contentobject.class_identifier]} - Download: {concat('http://', ezini('SiteSettings', 'SiteURL', 'site.ini'), '/content/download/',$item.item_object.contentobject.data_map.$download_attribute.content.id,'/',$item.item_object.contentobject.data_map.$download_attribute.content.data_map.file.id)|ezurl('no')} {undef $download_attributes} {undef $download_attribute} {/if} {/foreach}
The code uses very similar logic to the workflow extension that we created in order to loop through each purchased product, see whether it is a downloadable product, and if so, access the node of the download file. Here, we are building a link to the "download" view of the "content" module, which is a special view that prompts the user through their browser to either download or save the file instead of showing a page. That view takes two parameters: the ID of the object in question, and the ID of the attribute containing the file. This is more efficient, user-friendly, and secure than linking to the page representing the download file's node in the media library. The e-mail text should now look something like this:
Le code utilise une logique très similaire à l'extension workflow que nous venons de créer afin de lister chaque produit acheté, de déterminer s'il s'agit d'un produit téléchargeable et, le cas échéant, d'accéder au nœud du fichier à télécharger. Nous souhaitons ici créer un lien pointant vers la vue download du module content, vue spécifique qui propose à l'utilisateur, via son navigateur, de télécharger ou de sauvegarder le fichier plutôt que d'afficher une page. Cette vue prend deux paramètres: le ID de l'objet en question et le ID de l'attribut contenant le fichier. Ceci est plus efficient, plus convivial et plus sécurisé que de créer un lien vers la page représentant le nœud du fichier à télécharger dans la médiathèque. Le texte du mail doit donc maintenant ressembler à ceci:
Product items 1x Constitution 1791 20,00 $: 20,00 $ - Download: http://monsite.fr/index.php/fre/content/download/173/969 Subtotal of items: $20.00
Order confirmation page / Page de confirmation de l'achat
The same download link from the confirmation e-mail should also be given on the order confirmation page (the last page shown in the checkout process). The default file used, and to be overridden in a design extension, is located at extension/ezwebin/design/ezwebin/templates/shop/orderview.tpl. The existing code loops through each purchased product in a table:
Le lien de téléchargement présent dans le mail de confirmation doit être également proposé sur la page de confirmation de la facture (la dernière page affichée par le processus de commande). Le fichier utilisé par défaut, qui devra être surchargé, se situe dans extension/ezwebin/design/ezwebin/templates/shop/orderview.tpl. Le code existant boucle (liste) chaque produit acheté pour les présenter dans un tableau:
{foreach $order.product_items as $product_item sequence array( 'bglight', 'bgdark' ) as $style} <tr class="{$style}"> <td> <a href={concat( "/content/view/full/", $product_item.node_id )|ezurl}>{$product_item.object_name}</a> </td>
We will add to that code to show the "content/download" links for each downloadable product:
Nous ajouterons le code nécessaire à l'affichage des liens content/download pour chacun des produits téléchargeable:
{foreach $order.product_items as $product_item sequence array( 'bglight', 'bgdark' ) as $style} <tr class="{$style}"> <td> <a href={concat( "/content/view/full/", $product_item.node_id )|ezurl}>{$product_item.object_name}</a> {def $download_classes = ezini('PayPerDownloadSettings', 'ContentClasses', 'payperdownload.ini')} {if $download_classes|contains($product_item.item_object.contentobject.class_identifier)} {def $download_attributes = ezini('PayPerDownloadSettings', 'Attributes', 'payperdownload.ini')} {def $download_attribute = $download_attributes[$product_item.item_object.contentobject.class_identifier]} <br /> - Download: <a href={concat('content/download/',$product_item.item_object.contentobject.data_map.$download_attribute.content.id,'/',$product_item.item_object.contentobject.data_map.$download_attribute.content.data_map.file.id)|ezurl()}>{$product_item.item_object.contentobject.data_map.$download_attribute.content.name}</a> {undef $download_attributes} {undef $download_attribute} {/if} </td>
This will product a result similar to the screenshot below:
Cela produira un résultat similaire à celui présenté par la capture d'écran ci-après:
The pay-per-download solution is now complete!
La solution Télécharger après paiement est maintenant terminée !
Table des matières
- Selling Pay-Per-Download Products - Vendre des produits à télécharger (dématérialisés)
- The buyer experience -- L'expérience client
- Setting up the product and permission structure -- Mise en oeuvre du produit et des permissions
- Payment process -- Processus de paiement
- Extension: Assigning permissions upon purchase part 1 -- Extension: assignation des droits à l'achat (partie 1)
- Pay-per-download extension part 2 -- Extension Pay-per-download (partie 2)
- Confirmation e-mails and pages -- Mails et pages de confirmation
- Extra considerations -- Considérations complémentaires
- Paypal Sandbox : comptes de test et devises
- Modification pour eZ Publish 4.3+














