Forum Replies Created

Viewing 5 replies - 16 through 20 (of 20 total)
  • It is annoying. Please disable the banner. It is just wont stop!

    We have detected you are running WooCommerce. Upgrade to All in One SEO Pack Pro to unlock our advanced eCommerce SEO features, including SEO for Product Categories and more.

    The options myst be Yes
    https://c2n.me/3NUf3Zl.png

    Thread Starter athinaok

    (@athinaok)

    And this is one similar version.

    Now text boxes have default value the latest gold value update.
    URL for the xml :

    https://www.igolder.com/gold-charts/Configure.aspx
    and params are EUR Gold per gram.

    <?php
    /**
     * Plugin Name: WooCommerce Gold Price
     * Plugin URI: https://omniwp.com.br/plugins/woocommerce-gold-price/
     * Description: Adds a Gold Price for 9k/14k/18k/22k/24k gold products, making easy to update their prices
     * Version: 2.4.4
     * Author: Gabriel Reguly
     * Author URI: https://omniwp.com.br
     * Requires at least: 3.5
     * Tested up to: 4.3
     *
     * Text Domain: woocommerce-gold-price
     * Domain Path: /languages/
     */
    if (!defined('ABSPATH'))
        exit; // Exit if accessed directly
    
    add_action('plugins_loaded', 'woocommerce_gold_price', 20);
    
    function woocommerce_gold_price()
    {
        if (!class_exists('Woocommerce')) {
            return false;
        }
    
        add_filter('plugin_action_links', 'woocommerce_gold_price_action_links', 10, 2);
    
        add_action('admin_init', 'woocommerce_gold_price_admin_init');
        add_action('admin_menu', 'woocommerce_gold_price_admin_menu', 10);
    
        load_plugin_textdomain('woocommerce-gold-price', false,
            '/woocommerce-gold-price/languages');
    
        function woocommerce_gold_price_admin_init()
        {
            global $weight_unit, $weight_unit_description;
    
            //		register_setting( $option_group, $option_name, $sanitize_callback );
            register_setting('woocommerce_gold_price_options',
                'woocommerce_gold_price_options', 'woocommerce_gold_price_validate_options');
    
            //		add_settings_section( $id, $title, $callback, $page );
            add_settings_section('woocommerce_gold_price_plugin_options_section', __('Gold Price Values',
                'woocommerce-gold-price'), 'woocommerce_gold_price_fields',
                'woocommerce_gold_price');
    
            //		add_settings_field( $id, $title, $callback, $page, $section, $args );
            add_settings_field('woocommerce_gold_price_options', __('Gold Price Values',
                'woocommerce-gold-price'), 'woocommerce_gold_price_fields',
                'woocommerce_gold_price_plugin_options_section', 'woocommerce_gold_price');
            $weight_unit = get_option('woocommerce_weight_unit');
            $weight_unit_description = array(
                'kg' => __('kg', 'woocommerce'),
                'g' => __('g', 'woocommerce'),
                'lbs' => __('lbs', 'woocommerce'),
                'oz' => __('oz', 'woocommerce'));
        }
    
        function woocommerce_gold_price_admin_menu()
        {
            global $menu, $woocommerce;
            if (current_user_can('manage_woocommerce')) {
    
                do_action('woocommerce_admin_css');
                /*
                //	add_submenu_page( $parent_slug,
                $page_title,
                $menu_title,
                $capability,
                $menu_slug,
                $function
                */
                add_submenu_page('woocommerce', __('Gold Price', 'woocommerce-gold-price'), __('Gold Price',
                    'woocommerce-gold-price'), 'manage_woocommerce', 'woocommerce_gold_price',
                    'woocommerce_gold_price_page');
            }
        }
    
        function get_xml_price($url)
        {
            $url = 'https://www.igolder.com/GoldData.ashx?type=Historical&hours=0&currency=EUR&tz=GTB%20Standard%20Time&unit=gr&output=xml';
    
            $xml_igolder = new SimpleXMLElement(file_get_contents($url));
            return (array )$xml_igolder->Price;
        }
    
        function woocommerce_gold_price_page()
        {
            global $weight_unit, $weight_unit_description;
            if (!isset($_REQUEST['settings-updated'])) {
                $_REQUEST['settings-updated'] = false;
            }
            if (false !== $_REQUEST['settings-updated']) {
    ?>
                <div id="message" class="updated notice">
                    <p><strong><?php _e('Your settings have been saved.',
    'woocommerce') ?></strong></p>
                </div>
                <?php
            }
    ?>
            <div class="wrap woocommerce">
                <div class="icon32 icon32-woocommerce-settings" id="icon-woocommerce"><br /></div>
                <h1><?php _e('Gold Price', 'woocommerce-gold-price') ?></h1>
                <form method="post" action="options.php" onSubmit="<?php $runs = $runs +
    1; ?>" );">
                    <?php
            settings_fields('woocommerce_gold_price_options');
            do_settings_sections('woocommerce_gold_price');
    ?>
    
                    <p class="submit">
                        <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
                    </p>
                </form>
                <h1><?php _e('Gold priced products', 'woocommerce-gold-price') ?></h1>
                <?php
            $options = get_option('woocommerce_gold_price_options');
            if (!$options) {
                $options = array(
                    '24k' => 0,
                    '22k' => 0,
                    '18k' => 0,
                    '14k' => 0,
                    '9k' => 0); //meta values
            }
            foreach ($options as $key => $value) {
    ?>
                    <h2><?php echo $key ?></h2>
                    <?php
    
                             $the_query = new WP_Query(array(
                'post_type' => 'product',
                'posts_per_page' => -1,
                'meta_key' => 'karat',
                'meta_value' => substr($key, 0, -1))); // meta values 24k, 22k, 18k, 14k, 9k  => 24, 22, 18, 14, 9 
    
                if (0 == $the_query->found_posts) {
                    echo '<p>' . __('No products', 'woocommerce-gold-price') . '</p>';
                } else {
                    echo '
    	<ol>';
                    // The Loop
                    while ($the_query->have_posts()):
                        $the_query->the_post();
                        $the_product = get_product($the_query->post->ID);
                        $edit_url = admin_url('post.php?post=' . $the_product->id . '&action=edit');
                        $message = '';
                        echo '
    		<li><a href="' . $edit_url . '">' . get_the_title() . '</a>';
                        if (!$the_product->has_weight()) {
                            $message = __('Product has zero weight, can\'t calculate price based on weight',
                                'woocommerce-gold-price');
                        } else {
                            $the_product->regular_price = $the_product->weight * $value;
    
                            $labor = get_post_meta($the_query->post->ID, 'labor', true);
    
                            $the_product->regular_price = $the_product->regular_price + $labor;
                            if ($the_product->is_on_sale()) {
                                $message = __('Product was on sale, can\'t calculate sale price',
                                    'woocommerce-gold-price');
                            }
                            echo ': ' . $the_product->weight . $weight_unit_description[$weight_unit] .
                                ' * ' . woocommerce_price($options[$key]) . ' + ' . $labor . ' € labor costs = ' .
                                woocommerce_price($the_product->regular_price);
                            if (false !== $_REQUEST['settings-updated']) {
                                update_post_meta($the_product->id, '_price', $the_product->regular_price);
                                update_post_meta($the_product->id, '_regular_price', $the_product->
                                    regular_price);
                                update_post_meta($the_product->id, '_sale_price', '');
                                update_post_meta($the_product->id, '_sale_price_dates_from', '');
                                update_post_meta($the_product->id, '_sale_price_dates_to', '');
                            }
                        }
                        echo ' ' . $message . '</li>';
                    endwhile;
                    echo '
    	</ol>';
                }
                // Restore original Query & Post Data
                wp_reset_query();
                wp_reset_postdata();
            }
    ?>
            </div>
            <?php
        }
    
        function woocommerce_gold_price_fields()
        {
            global $weight_unit, $weight_unit_description;
    
            $options = get_option('woocommerce_gold_price_options');
            $currency_pos = get_option('woocommerce_currency_pos');
            $currency_symbol = get_woocommerce_currency_symbol();
    ?>
            <table class="form-table widefat">
                <thead>
                    <tr valign="top">
                        <th scope="col">?<?php _e('Karats','woocommerce-gold-price') ?></th>
                        <th scope="col"><?php _e('Price', 'woocommerce') ?></td>
                        <th scope="col"><?php _e('Weight Unit', 'woocommerce') ?></td>
                    </tr>
                </thead>
                <!--New Line with Option-->
                <tr valign="top">
                    <th scope="row">?<label for="woocommerce_gold_price_options_24">24k</label></th>
                    <td>
                        <?php
            $xml_price = get_xml_price();
    
            // $input = '<input id = "woocommerce_gold_price_options_24" name = "woocommerce_gold_price_options[24k]" size = "10" type = "text" value = "' . $options['24k'] . '" />';
            $input = '<input id = "woocommerce_gold_price_options_24" name = "woocommerce_gold_price_options[24k]" size = "10" type = "text" value = "' .
                round($xml_price['@attributes']['Value'] * 1, 2) . '" />';
    
            switch ($currency_pos) {
                case 'left':
                    echo $currency_symbol . $input;
                    break;
                case 'right':
                    echo $input . $currency_symbol;
                    break;
                case 'left_space':
                    echo $currency_symbol . '?
                ' . $input;
                    break;
                case 'right_space':
                    echo $input . '?
                ' . $currency_symbol;
                    break;
            }
    ?>
                    </td>
                    <td><?php echo $weight_unit_description[$weight_unit] ?></td>
                </tr>
                <!--New meta value End-->
                <!--New Line with meta value-->
                <tr valign="top" class="alternate">
                    <th scope="row">?<label for="woocommerce_gold_price_options_22">22k</label></th>
                    <td>
                        <?php
            //	$input = '<input id = "woocommerce_gold_price_options_22" name = "woocommerce_gold_price_options[22k]" size = "10" type = "text" value = "' . $options['22k'] . '" />';
            $get_xml_price = get_xml_price();
    
            $input = '<input id = "woocommerce_gold_price_options_22" name = "woocommerce_gold_price_options[22k]" size = "10" type = "text" value = "' .
                round($xml_price['@attributes']['Value'] * 0.917, 2) . '" />';
            switch ($currency_pos) {
                case 'left':
                    echo $currency_symbol . $input;
                    break;
                case 'right':
                    echo $input . $currency_symbol;
                    break;
                case 'left_space':
                    echo $currency_symbol . '?
                ' . $input;
                    break;
                case 'right_space':
                    echo $input . '?
                ' . $currency_symbol;
                    break;
            }
    ?>
                    </td>
                    <td><?php echo $weight_unit_description[$weight_unit] ?></td>
                </tr>
                <!--New meta value End-->
                <!--New Line with meta value-->
                <tr valign="top">
                    <th scope="row">?<label for="woocommerce_gold_price_options_18">18k</label></th>
                    <td>
                        <?php
            // $input = '<input id = "woocommerce_gold_price_options_18" name = "woocommerce_gold_price_options[18k]" size = "10" type = "text" value = "' . $options['18k'] . '" />';
            $input = '<input id = "woocommerce_gold_price_options_18" name = "woocommerce_gold_price_options[18k]" size = "10" type = "text" value = "' .
                round($xml_price['@attributes']['Value'] * 0.75, 2) . '" />';
            switch ($currency_pos) {
                case 'left':
                    echo $currency_symbol . $input;
                    break;
                case 'right':
                    echo $input . $currency_symbol;
                    break;
                case 'left_space':
                    echo $currency_symbol . '?
                ' . $input;
                    break;
                case 'right_space':
                    echo $input . '?
                ' . $currency_symbol;
                    break;
            }
    ?>
                    </td>
                    <td><?php echo $weight_unit_description[$weight_unit] ?></td>
                </tr>
                <!--New meta value End-->
                <!--New Line with meta value-->
                <tr valign="top" class="alternate">
                    <th scope="row">?<label for="woocommerce_gold_price_options_14">14k</label></th>
                    <td>
                        <?php
            // $input = '<input id = "woocommerce_gold_price_options_14" name = "woocommerce_gold_price_options[14k]" size = "10" type = "text" value = "' . $options['14k'] . '" />';
            $input = '<input id = "woocommerce_gold_price_options_14" name = "woocommerce_gold_price_options[14k]" size = "10" type = "text" value = "' .
                round($xml_price['@attributes']['Value'] * 0.583, 2) . '" />';
    
            switch ($currency_pos) {
                case 'left':
                    echo $currency_symbol . $input;
                    break;
                case 'right':
                    echo $input . $currency_symbol;
                    break;
                case 'left_space':
                    echo $currency_symbol . '?
                ' . $input;
                    break;
                case 'right_space':
                    echo $input . '?
                ' . $currency_symbol;
                    break;
            }
    ?>
                    </td>
                    <td><?php echo $weight_unit_description[$weight_unit] ?></td>
                </tr>
                <!--New meta value End-->
                <!--New Line with meta value-->
                <tr valign="top" >
                    <th scope="row">?<label for="woocommerce_gold_price_options_9">9k</label></th>
                    <td>
                        <?php
            //$input = '<input id = "woocommerce_gold_price_options_9" name = "woocommerce_gold_price_options[9k]" size = "10" type = "text" value = "' . $options['9k'] . '" />';
            $input = '<input id = "woocommerce_gold_price_options_9" name = "woocommerce_gold_price_options[9k]" size = "10" type = "text" value = "' .
                round($xml_price['@attributes']['Value'] * 0.375, 2) . '" />';
    
            switch ($currency_pos) {
                case 'left':
                    echo $currency_symbol . $input;
                    break;
                case 'right':
                    echo $input . $currency_symbol;
                    break;
                case 'left_space':
                    echo $currency_symbol . '?
                ' . $input;
                    break;
                case 'right_space':
                    echo $input . '?
                ' . $currency_symbol;
                    break;
            }
    ?>
                    </td>
                    <td><?php echo $weight_unit_description[$weight_unit] ?></td>
                </tr>
                <!--New meta value End-->
    
                <tr valign="top" >
                    <td>
                        Last XML Update <?php echo $xml_price['@attributes']['Date'] ?>
                    </td>
                </tr>
    
            </table>
    
            <?php
        }
    
        function woocommerce_gold_price_validate_options($input)
        {
            foreach ($input as $key => $value) {
                $input[$key] = wp_filter_nohtml_kses($value);
            }
            return $input;
        }
    
        // Display a Settings link on the main Plugins page
        function woocommerce_gold_price_action_links($links, $file)
        {
            if (plugin_basename(__file__) == $file) {
                $woocommerce_gold_price_settings_link = '<a href = "' . get_admin_url() .
                    'admin.php?page=woocommerce_gold_price">' . __('Settings') . '</a>';
                // make the 'Settings' link appear first
                array_unshift($links, $woocommerce_gold_price_settings_link);
            }
            return $links;
        }
    
    }
    
    ?>

    Go to Kraken.io Settings -> Advance settings -> Show metadata reset per image: Reset All Images

    Hello,
    It seems when we check option plugin will not use po files.
    I am from Greece and I face the same issue.
    Since i have translated all data and save GR po file,I am able to see the translated data in plug in options.
    On the other hand on front end, plug in display the english language.
    Could you please fix the bug?

Viewing 5 replies - 16 through 20 (of 20 total)