Home Forums Themes Support Gecko Woocommerce lay-out and text

Topic Resolution: Resolved
Viewing 4 reply threads
  • Author
    Posts
    • #17011

      Hello,

      In my webshop i sell items in a box. Is it possible for me to show the items what they cost per unit and what the cost per box?

      1. Is it possible to show both prices? Cost per unit / cost per box?
      2. And/Or is it possible to show: Cost per box (per doos) in front of the price (see red text)?
      3. Is it possible to show the price per unit in the shop. And in the cart, the price per box?
    • #17027

      Hi.

      1. What’s the current price, cost per unit / cost per box? and how can you add the second price? in product detail setting?

      2. Add this code in functions.php file of child theme https://pastebin.com/raw/SAQah5LQ

      3. Same question #1 before give you an instruction

    • #17040

      Hi Foster,

      1. Thats the problem. I can only use one price. So i am looking for a place to put the other price per unit.
        But is it possible to place two prices? Or can you give me a good idea of a good place to place the second price?
        Is it possible to make another line between the discription and the price of the box?
      2. The price per items is different for every item i sell.

       

      I can make a new tab. Is it possiple to display this tab on the frontpage between the discription and the price per box?
      https://www.horecakaarsendirect.nl/product/combilight-houder-windlicht/

      Somthing like this, or do you have a better idea?

       

    • #18496
      This reply has been marked as private.
    • #18509

      Hi,

      Please add below code to gecko-child > functions.php

      /*
       * Prefix and sufix to price
       * Author: https://levantoan.com
       */
       
      /*Add default setting*/
      function devvn_woocommerce_general_settings( $array ) {
       
          $array[] = array( 'name' => __( 'Prefix and suffix to price', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'woocommerce_presuffix_settings' );
       
          $array[] = array(
              'title'    => __( 'Prefix', 'woocommerce' ),
              'desc'     => __( 'Add prefix to price. Leave blank to disable.', 'woocommerce' ),
              'id'       => 'devvn_woocommerce_price_prefix',
              'desc_tip' => true,
              'type'     => 'text',
          );
       
          $array[] = array(
              'title'    => __( 'Suffix', 'woocommerce' ),
              'desc'     => __( 'Add suffix to price. Leave blank to disable.', 'woocommerce' ),
              'id'       => 'devvn_woocommerce_price_suffix',
              'desc_tip' => true,
              'type'     => 'text',
          );
       
          $array[] = array( 'type' => 'sectionend', 'id' => 'woocommerce_presuffix_settings');
          return $array;
      };
      add_filter( 'woocommerce_general_settings', 'devvn_woocommerce_general_settings', 10, 1 );
       
      /*Add metabox to product*/
      add_action( 'woocommerce_product_options_general_product_data', 'devvn_presuffix_products' );
      function devvn_presuffix_products() {
          //Add metabox prefix to product
          woocommerce_wp_text_input( array(
              'id' => '_product_prefix',
              'label' => 'Prefix',
              'description' => 'Add prefix to price. Leave blank to default.',
              'desc_tip' => 'true',
          ) );
          //Add metabox suffix to product
          woocommerce_wp_text_input( array(
              'id' => '_product_suffix',
              'label' => 'Suffix',
              'description' => 'Add suffix to price. Leave blank to default.',
              'desc_tip' => 'true',
          ) );
      }
       
      /*Save metabox prefix and suffix*/
      add_action( 'woocommerce_process_product_meta', 'devvn_presuffix_products_save' );
      function devvn_presuffix_products_save( $post_id ) {
          if ( ! empty( $_POST['_product_prefix'] ) ) {
              update_post_meta( $post_id, '_product_prefix', esc_attr( $_POST['_product_prefix'] ) );
          }
          if ( ! empty( $_POST['_product_suffix'] ) ) {
              update_post_meta( $post_id, '_product_suffix', esc_attr( $_POST['_product_suffix'] ) );
          }
      }
       
      /*Add to price html*/
      add_filter( 'woocommerce_get_price_html', 'bbloomer_price_prefix_suffix', 100, 2 );
      function bbloomer_price_prefix_suffix( $price, $product ){
          $prefix = get_option( 'devvn_woocommerce_price_prefix');
          $suffix = get_option( 'devvn_woocommerce_price_suffix');
       
          $prefix_product = get_post_meta($product->get_ID(), '_product_prefix', true);
          $suffix_product = get_post_meta($product->get_ID(), '_product_suffix', true);
       
          if($prefix_product) $prefix = $prefix_product;
          if($suffix_product) $suffix = $suffix_product;
       
          $prefix = ($prefix)?'<span class="devvn_woocommerce_price_prefix">'.$prefix.'</span>':'';
          $suffix = ($suffix)?'<span class="devvn_woocommerce_price_suffix">'.$suffix.'</span>':'';
       
          $price = $prefix.$price.$suffix;
          return apply_filters( 'woocommerce_get_price', $price );
      }

      Refer topic https://levantoan.com/noi-dung-vao-truoc-va-sau-gia-cua-san-pham-trong-woocommerce/

      Best regards

      Harry
      Premium Wordpress themes and plugins, Best WooCommerce theme https://themeforest.net/user/janstudio/portfolio?ref=janstudio

Viewing 4 reply threads

You must be logged in to reply to this topic.