Okay
  Public Ticket #3237338
Admin emails : remove slug
Closed

Comments

  •  2
    julienpesce-1980 started the conversation

    Hello,

    My client would like the events slugs (permalink) to be removed from the admin and customers emails, because she duplicates posts so it doesn't lead to the right events. Anyway, she doesn't want these links to appear and it looks like they are generated by STEC.

    Is it possible to remove them please ?

    Thank you for the help !

    Attached files:  permalink.jpg

  •  783
    Zhivko replied

    Hi,

    Sorry there's difference between slug and permalink. 

    To remove permalinks from emails go to Dashboard -> STEC -> General -> Email Notifications tab and edit each template.

    Remove {{permalink}} placeholder from each template.

    5140054121.png

    To remove the slug field from the admin you will have to edit file

    wp-content / plugins / stachethemes_event_calendar / view / admin / events / tabs / general.php

    lines 13 and 14

    6124327692.png

    Either comment them or delete them.


    Stachethemes Developer

  •  2
    julienpesce-1980 replied

    Thank Zhivko for the fast answer.

    But my problem concerns the product summary in the emails customers receive when they book an event. It appears in the cart and the checkout also.

    I know Woocommerce sends these infos but it looks like the Event Calendar generates them, am I wrong ?

    See attached for a better picture.


    Attached files:  Capture d’écran 2023-03-03 à 14.23.23.jpg
      Capture d’écran 2023-03-01 à 11.23.37.jpg

  •  783
    Zhivko replied

    I see. I misunderstood your question.

    To remove the permalink you will have to override the checkout function.

    Place the code below in your theme or child-theme functions.php file:

    // Remove permalink from ticket meta data
    add_action('wp_footer', function () {
        ?>
        <script type="text/javascript">
            (function($) {
                $(function() {
                    if (typeof window.StecBooking === 'undefined') {
                        return;
                    }
                    window.StecBooking.prototype.checkOut = function() {
                        var parent = this;
                        var helper = this.settings.helper;
                        var event = this.settings.event;
                        var offset = this.settings.offset;
                        var eventStartDate = helper.beautifyDate(moment.tz(event.start_date, event.timezone).add(offset, 'seconds'));
                        var eventEndDate = helper.beautifyDate(moment.tz(event.end_date, event.timezone).add(offset, 'seconds'));
                        var $popup = $(this.settings.popup);
                        var items = [];
                        var coupon = $popup.find('input[name="discount"]').val().trim();
                        $.each($popup.find('.stec-booking-item'), function() {
                            var quantity = Math.max(0, parseInt($(this).find('.stec-booking-item-quantity').val(), 10));
                            var item;
                            if (quantity > 0) {
                                item = {
                                    id: $(this).data('id'),
                                    quantity: quantity,
                                    variables: {
                                        event_id: event.id,
                                        event_title: event.title,
                                        event_offset: offset,
                                        event_start: eventStartDate,
                                        event_end: eventEndDate,
                                        // event_permalink: helper.getPermalink(event.permalink, parent.settings.offset)
                                    }
                                };
                                items.push(item);
                            }
                        });
                        if (items.length > 0) {
                            this.addToCart(items, coupon, function(result) {
                                if (result.error) {
                                    if (result.msg) {
                                        parent.displayErrorMessage(result.msg);
                                    }
                                } else {
                                    if (result.checkout) {
                                        window.open(result.checkout, '_self');
                                    }
                                }
                            });
                        } else {
                            this.displayErrorMessage(__('No tickets selected'));
                        }
                    }
                });
            })(window.jQuery)
        </script>
    <?php
    });
    

    Stachethemes Developer

  •  2
    julienpesce-1980 replied

    Hello Zhivko,

    Thank you but it doesn't work, the permalinks are still in the emails customers receive.

    Maybe because I don't use tickets ?

    My events are just products from Woocommerce. The permalinks look like [mywebsite.fr]/event/[name of the woocommerce product]

  •  783
    Zhivko replied

    Apologies, I thought it was for tickets.

    For products use this code:

    // Remove permalink from product meta data
    add_action('wp_footer', function () {
        ?>
        <script type="text/javascript">
            (function($) {
                $(function() {
                    if (typeof window.StecShop === 'undefined') {
                        return;
                    }
                    var moment = window.moment;
                    var DB = new window.StecDB();
                    const __ = new window.StecHelper().lang;
                    window.StecShop.prototype.addToCart = function($productContainer, params) {
                        if (params && params.permalink) {
                            delete params.permalink;
                        }
                        var parent = this;
                        var request = DB.newRequest();
                        request.setData({
                            action: 'stec_public_ajax_action',
                            task: 'shop_add_to_cart',
                            data: {
                                stec_shop_item: params
                            }
                        });
                        request.setBefore(function() {
                            $productContainer.find('.stec-toast').remove();
                            parent.blockActions($productContainer);
                        });
                        request.setCallback(function(result) {
                            var toastCss = {
                                position: 'absolute'
                            };
                            var toastContainer = $productContainer;
                            if (parent.settings.$instance.hasClass('stec-media-small') || parent.settings.$instance.hasClass('stec-layout-single-media-small')) {
                                toastCss = false;
                                toastContainer = 'body';
                            }
                            parent.unblockActions($productContainer);
                            if (result && 0 === result.error) {
                                parent.settings.helper.toast(__('Item added to your cart'), toastContainer, 3000, toastCss);
                                // update cart fragments                            
                                if (result.cart && result.cart.fragments) {
                                    for (let key in result.cart.fragments) {
                                        if (result.cart.fragments.hasOwnProperty(key)) {
                                            $(key).replaceWith(result.cart.fragments[key]);
                                        }
                                    }
                                }
                            } else {
                                parent.settings.helper.toast(result.msg, toastContainer, 3000, toastCss);
                            }
                        });
                        DB.query(request);
                    };
                });
            })(window.jQuery)
        </script>
    <?php
    });

    Stachethemes Developer

  •  2
    julienpesce-1980 replied

    I pasted the code in my theme's function.php and it still doesn't work.

    The permalink still appears in the client's email... any idea ?

  •  783
    Zhivko replied

    There is a small error in the code here:

    8214757072.png

    This part:

    if (result.cart && result.cart.fragments) {

    should be on new line like this:

    5920608984.png

    Can you correct this mistake and check again if the permalink is there?




    Stachethemes Developer

  •  2
    julienpesce-1980 replied

    Yes it works !

    Thank you Zhivko !