Placeholder for description

Home Forums WP Shop Styling Placeholder issues and requests Placeholder for description

This topic contains 5 replies, has 2 voices, and was last updated by  Hannes 3 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #731 Reply

    Missy

    Hi,

    Love the plugin, I need to add the description of a product to emails because I need custom content to show up in every email based on the product purchased (i.e event tickets need time, date, directions, etc..and each event has different info). So I am officially requesting this as an option in the checkout form options dropdown.

    However, I need this now. I am more than comfortable coding this functionality myself, so in the meantime I would just like to basically append the description to any emails sent to customers and hopefully the feature will be in a future release.

    Having said that, can you tell me which file and the best place to add this in your code? There are several files in your plugin that covers the additional functionality so it would help if I could narrow down the right file for a simple addition.

    Thanks for any help you can provide!
    Missy

    #732 Reply

    Missy

    Just as an aside, I am thinking an even easier way to do this would be to simply add in the custom meta section of a product and just append that…

    #755 Reply

    Missy

    I was able to do this…in the end I used I used category descriptions and it was really easy to add custom content to an email by product.

    For example I have a parent cat Events…and then I use sub cats for each event. So Events->Event 1. Then I added the content I needed sent with Event 1 as the description.

    In your plugin I added 2 lines of code to class-haetshopstyling.php right after the below line of code (line 608 in my editor):

    $params[]= array('unique_name'=>'#productstable#','value'=>$products_table);

    My 2 new lines:


    $params[]= array('unique_name'=>'catdesc','value'=>(get_term_by('slug', 'event-one', 'wpsc_product_category')->description));

    This allows for me to add {catdesc} to my “Email Content – Payment Successful” template and it will display my description…html formatting and all.

    I will need to add a line for each subcat, but this fits my needs for the moment. Obviously this could be improved upon with short code type functionality i.e {catdesc term=1}. Anyway hope this helps someone or gives you a cool idea on how to add a similar feature to your plugin. :)

    #770 Reply

    Hannes
    Keymaster

    Hi Missy,
    Thanks for sharing your idea and code with us.
    Great work!

    #779 Reply

    Missy

    No problem!

    One additional note…while this will work for one cat description if you are trying to display multiple it will not…so I did have to write some additional code, including a select statement from the taxonomy relationships table so I could tell which category a product belongs to. Again, not every one will need something like this, but it is an easy ay to add additional content to an email. I am sure there is a more elegant way to code this, but I will put my additions here as well…Update the type-custom-taxonomy-name-here to be the product category name and the number ids to the ones that match for each cat.


    $myprodid = $item['prodid'];
    $mysql = "SELECT term_taxonomy_id
    FROM
    ".$wpdb->prefix."term_relationships
    WHERE object_id = ".$myprodid;
    $mysql2 = $wpdb->get_results($mysql, ARRAY_A);
    $mycatid = $mysql2[0]['term_taxonomy_id'];

    if ($mycatid == 19) {
    $params[]= array('unique_name'=>'my_catdesc','value'=>(get_term_by('slug', 'type-custom-taxonomy-name-here', 'wpsc_product_category')->description));
    }
    if ($mycatid == 16) {
    $params[]= array('unique_name'=>'my_catdesc','value'=>(get_term_by('slug', 'type-custom-taxonomy-name-here', 'wpsc_product_category')->description));
    }
    if ($mycatid == 20) {
    $params[]= array('unique_name'=>'my_catdesc','value'=>(get_term_by('slug', 'type-custom-taxonomy-name-here', 'wpsc_product_category')->description));
    }

    #14436 Reply

    Hannes
    Keymaster

    To simplify this process for future modifications I’ve added a filter to add custom placeholders:
    http://wpshopstyling.com/custom-placeholder/

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Placeholder for description
Your information: