Support » Plugin: YITH WooCommerce Gift Cards » Auto-generate code for cards created by admin

  • Resolved David Relich

    (@relichd)


    Hi,

    Testing your plugin, which works very nicely for what I need. The automated process when a customer creates the card and pays for it online is perfect.

    However, I was wondering if there’s an option to auto-generate the card code for cards created by website admin via the wp-admin area. At the moment, it needs to be typed in manually, which (considering the complexity of the code) is not ideal.

    I should very much like to see the option to have the code generated automatically, based on the template configured in settings.

    Thank you.

    David.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter David Relich

    (@relichd)

    Contacted support directly since I am using a paid version.

    Thread Starter David Relich

    (@relichd)

    For anybody needing it, this is the code I was sent by Francisco. It goes to functions.php of your active theme. Works like a charm!

    if ( ! function_exists( 'ywgc_generate_automatic_code' ) ) {
    
     function ywgc_generate_automatic_code( $post ) {
    
     if ( get_post_type() != 'gift_card' ) {
     return;
     }
    
     if ( $post->post_title != '' ) {
     return;
     }
    
     $title = YITH_WooCommerce_Gift_Cards_Premium::get_instance()->generate_gift_card_code();
    
          ?>
     <script type="text/javascript">
     jQuery(document).ready(function ($) {
                $("#title").val("<?php echo $title; ?>");
    
     });
     </script>
     <?php
     }
    
       add_action( 'edit_form_after_title', 'ywgc_generate_automatic_code' );
    }
    Plugin Support Fran Mendoza

    (@franmglez92)

    Hello David,
    thanks for contacting us! 🙂

    Unfortunately, the code given by me in the premium support will not work properly in the free version, so I suggest you to remove your reply to avoid confusion with the customer that uses the free version, please.

    Thank you very much for your understanding!

    Have a nice day!

    Thread Starter David Relich

    (@relichd)

    Ah, sorry. Didn’t realise.

    I can’t see any option to edit existing comment, or delete it, though? Not even an option to delete the whole thread…

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.