Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter('woo_pdf_totals', 'woo_pdf_change_totals');
- function woo_pdf_change_totals($totals) {
- $taxonomy = 'product_cat';
- $orderby = 'name';
- $show_count = 0; // 1 for yes, 0 for no
- $pad_counts = 0; // 1 for yes, 0 for no
- $hierarchical = 1; // 1 for yes, 0 for no
- $title = '';
- $empty = 0;
- $args = array(
- 'taxonomy' => $taxonomy,
- 'orderby' => $orderby,
- 'show_count' => $show_count,
- 'pad_counts' => $pad_counts,
- 'hierarchical' => $hierarchical,
- 'title_li' => $title,
- 'hide_empty' => $empty
- );
- $all_categories = get_categories( $args );
- if($all_categories) {
- foreach($all_categories as $sub_category) {
- $category = $sub_category->name ;
- }
- }
- if ($category == 'korting25') {
- (int)$korting = 0.25;
- $kortingNaam = 'Korting 25%';
- } else if ($category == 'korting30') {
- (int)$korting = 0.30;
- $kortingNaam = 'Korting 30%';
- } else {
- (int)$korting = 0.2;
- }
- $order_pdf_total = $totals['subtotal']['value'];
- $order_pdf_discount = $totals['subtotal']['value'] / 121 * 100 * $korting;
- $order_pdf_discounted = $totals['subtotal']['value'] /121 * 100 - $order_pdf_discount;
- $new_totals = array(
- $totals['total'] = array(
- 'name' => "Totaal",
- 'value' => (double) $order_pdf_total,
- ),
- $totals['discount'] = array(
- 'name' => $kortingNaam,
- 'value' => (double) $order_pdf_discount,
- ),
- $totals['discounted'] = array(
- 'name' => "Totaal incl. 20% korting",
- 'value' => (double) $order_pdf_discounted,
- )
- );
- return $new_totals;
- }
- /* Discount in mail. */
- add_action('woocommerce_email_order_details', 'new_order_custom_email_notification', 20, 4 );
- function new_order_custom_email_notification( $order, $sent_to_admin, $plain_text, $email )
- {
- // Only for "New order" email notifications (admin)
- if( $email->id != 'new_order' ) return;
- $order_total = floatval($order->get_subtotal());
- $order_total_discount = $order_total * 0.2;
- $order_total_discounted = $order_total - $order_total_discount;
- // CSS style
- $styles = '<style>
- .discount-info table{width: 100%; font-family: \'Helvetica Neue\', Helvetica, Roboto, Arial, sans-serif;
- color: #737373; border: 1px solid #e4e4e4; margin-bottom:8px;}
- .discount-info table th, table.tracking-info td{text-align: left; border-top-width: 4px;
- color: #737373; border: 1px solid #e4e4e4; padding: 12px; width:58%;}
- .discount-info table td{text-align: left; border-top-width: 4px; color: #737373; border: 1px solid #e4e4e4; padding: 12px;}
- </style>';
- // HTML Structure
- $html_output = '<h2>'.__('Inkoopprijs').'</h2>
- <div class="discount-info">
- <table cellspacing="0" cellpadding="6">
- <tr>
- <th>' . __('Totaal') . '</th>
- <td>' . wc_price($order_total) . '</td>
- </tr>
- <tr>
- <th>' . __('Korting 20%') . '</th>
- <td>' . wc_price($order_total_discount) . '</td>
- </tr>
- <tr>
- <th>' . __('Totaal incl. 20% korting') . '</th>
- <td>' . wc_price($order_total_discounted) . '</td>
- </tr>
- </table>
- </div><br>'; // HTML (end)
- // Output CSS + HTML
- echo $styles . $html_output;
- }
- define('EPICO_THEME_SLUG', 'Ep');
- define('EPICOMEDIA_THEME_SLUG', 'vitrine');
- define('VITRINE_THEME_SLUG', 'vitrine');
- /**************************************************
- FOLDERS
- **************************************************/
- define('EPICO_THEME_DIR', get_parent_theme_file_path());
- define('EPICO_THEME_LIB', EPICO_THEME_DIR . '/lib');
- define('EPICO_THEME_PLUGINS', EPICO_THEME_DIR . '/plugins');
- define('EPICO_THEME_CSS', EPICO_THEME_DIR . '/assets/css');
- /**************************************************
- FOLDER URI
- **************************************************/
- define('EPICO_THEME_URI', get_parent_theme_file_uri());
- define('EPICO_THEME_LIB_URI', EPICO_THEME_URI . '/lib');
- define('EPICO_THEME_ASSETS_URI', EPICO_THEME_URI . '/assets');
- define('EPICO_THEME_IMAGES_URI', EPICO_THEME_ASSETS_URI . '/img');
- /**************************************************
- Text Domain
- **************************************************/
- load_theme_textdomain( 'vitrine' , EPICO_THEME_DIR . '/languages' );
- /**************************************************
- Content Width
- **************************************************/
- if ( !isset( $content_width ) ) $content_width = 1170;
- /**************************************************
- LIBRARIES
- **************************************************/
- require_once(EPICO_THEME_LIB . '/framework.php');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement