Help to Complete My Custom Code

MultivendorX Pro

Resolved
Viewing 12 reply threads
  • Author
    Posts
    • #190605
      Chris
      Participant

      Hi support,

      I’m using this code to convert any products with price of $0 to the words “FREE”. Since the membership plans are from the products, so it shows the word “FREE” when it is in product view. However, I would like to make the membership plans shown during registration for vendor that cost $0 to show the word “FREE” too. Could you please help me to modify or add the code filters and strings?

      add_filter( ‘woocommerce_get_price_html’, ‘change_zero_price_display’, 10, 2 );
      function change_zero_price_display( $price, $product ) {
      if (empty($product->get_price()) || $product->get_price() == 0) { // If price is not entered or set to 0
      $price = __( ‘FREE’, ‘woocommerce’ );
      }
      return $price;
      }

      Thank you very much!

    • #190632

      The team is looking into the matter . Kindly provide them some time.

    • #190656
      Chris
      Participant

      Okay noted. Thank you so much!

    • #190688
      promita
      Keymaster

      Hi @Chris, You need to overwrite mvx-vendor-membership_template_vendor_plan.php template file and replace the code of line no 96 with this below code

      
      <div class="wvm_price wvm_price_<?php echo $index; ?>" style="color: <?php echo get_mvx_vendor_settings('_plan_price_color', 'payment_membership_design'); ?>"><?php echo ($product->get_regular_price() == 0 || empty($product->get_regular_price())) ? __( 'FREE', 'mvx-pro' ) : wc_price($initial_billing_amt); ?></div>
      
      Copy
    • #190828
      Chris
      Participant

      Hi @promita,
      Thanks for the information and code provided. I’ve tested and it works.
      However, I have 2 questions here to clear my doubts.
      1) To prevent from overwriting it again on the next update of mvx pro, I should override this template, mvx-vendor-membership_template_vendor_plan.php in my child theme right?
      2) The notes on the template file wrote this “Override this template by copying it to yourtheme/mvx-vendor-membership/mvx-vendor-membership_template_vendor_plan.php”. Does this mean that I have to add a new file named mvx-vendor-membership in my child theme and then upload the overwritten “mvx-vendor-membership_template_vendor_plan.php” into the file?

    • #190862

      Hi @Chris, yes you are right for both procedure.
      Let us know if you need any further help.

    • #191151
      Chris
      Participant

      Hi, thanks for clarifying. Anyway, I replaced the line of code mentioned previously through ftp access, which will work until the next update. However, I need some help here. I’d prefer to use the Code Snippets plugin for any child theme related customization for a hassle-free experience. I tried to copy and add the whole modified mvx-vendor-membership_template_vendor_plan.php template using the plugin but not sure why it couldn’t override. Is it possible if I want to request some php function codes or anything regarding to text customization so that I can refer to it and modify any parts of whenever I wanted to do so.

      Thanks.

    • #191226

      @Chris, you can override the template only if you edit this via theme.

      Currently, we don’t have a hook/filter for those parts. I have requested the team to check whether we can add such filter in our next update/

    • #191268
      Chris
      Participant

      Alright, noted. Thanks for the help. Btw is this the link that showing all the available hooks? https://github.com/multivendorx/dc-woocommerce-multi-vendor/blob/master/classes/class-wcmp-vendor-hooks.php
      If there is any other available docs or hooks/filters directory which I missed it out in my own searching, please guide me thanks!

    • #191281
      Chris
      Participant

      Hi moumita,
      I have another question here regarding to overriding it via child theme. I checked on some php files and noticed that only files in the templates file have the comments: “Override this template by copying it to yourtheme/mvx-vendor-membership/mvx-vendor-membership_template_vendor_plan.php”. Some other php files which I’m interested in making some changes doesn’t have this type of comments. So, my question is:
      1) If I want to customize some text and add some css styling, but the php files doesn’t have the comments:“Override this template by copying it to yourtheme/mvx-vendor-membership/mvx-vendor-membership_template_vendor_plan.php”, does this means that the changes will gone too when the plugin is updated even if I’m doing the same way by uploading the modified file into my child theme?

      Thanks for the help.

    • #191301
      This reply has been marked as private.
    • #191422
      Chris
      Participant

      Okay, thank you for the information.

    • #191447

      Hope your query is solved . We are closing this thread as of now . If you face issue or need help in future please create a new thread.

Viewing 12 reply threads

The topic ‘Help to Complete My Custom Code’ is closed to new replies.