Cómo hacer que woocommerce-pdf-invoice funcione con WOOCS
El complemento woocommerce-pdf-invoice le permite imprimir facturas en formato pdf. Pero una cosa: no hay filtros ni acciones para que funcione bien con WOOCS. Así que decidí investigar esta pregunta y resolver estas tareas pirateando el código del complemento woocommerce-pdf-invoice. Puede hacer lo mismo si desea utilizar woocommerce-pdf-invoice con WOOCS.
- Ve a plugins / woocommerce-pdf-invoice / includes / woo-pdf-invoice.class.php
- Necesitamos hacer cambios en 8 lugares en el archivo. woo-pdf-factura.clase.php
- Finf función total y código de cambio en el siguiente:
public function total () {if (class_exists ('WOOCS')) {return (doble) WOOCS :: normalize_order_data ($ this-> orderData-> id, $ this-> orderData-> order_total); } else {return (doble) $ this-> orderData-> order_total; }}
- Obtendrá algo como esto:
- Luego busque la función row_total e inserte el siguiente código allí como en la pantalla:
if (class_exists ('WOOCS')) {$ line_subtotal = WOOCS :: normalize_order_data ($ this-> orderData-> id, $ line_subtotal); }
- Luego busque la función item_price y reemplace el código por esto como en la pantalla:
if ((((doble) $ precio) * (int) $ artículo ['cantidad']) == (doble) $ esto-> fila_total ($ artículo, $ esto-> orderData)) {if (class_exists ('WOOCS ')) {return WOOCS :: normalize_order_data ($ this-> orderData-> id, $ price); } else {devolver $ precio; }} else {if (class_exists ('WOOCS')) {return WOOCS :: normalize_order_data ($ this-> orderData-> id, $ price); } else {devolver $ precio; }}
- Luego busque la función get_totals y reemplace el siguiente código como en la pantalla:
if (class_exists ('WOOCS')) {$ totales ['subtotal'] = array ('name' => $ this-> invoiceOptions ['woo_pdf_title_subtotal'], 'value' => (doble) WOOCS :: normalize_order_data ($ this-> orderData-> id, $ subtotal),); } else {$ totales ['subtotal'] = array ('nombre' => $ this-> invoiceOptions ['woo_pdf_title_subtotal'], 'valor' => (doble) $ subtotal,); }
- En la misma función, busque la cadena // Muestra los impuestos debajo del total solo si se muestra el subtotal, incluidos los impuestos, e inserte el siguiente código:
if (class_exists ('WOOCS')) {$ totales ['total'] = array ('name' => $ this-> invoiceOptions ['woo_pdf_title_total'], 'value' => (doble) WOOCS :: normalize_order_data ($ this-> orderData-> id, $ this-> orderData-> order_total),); } else {$ totales ['total'] = array ('nombre' => $ this-> invoiceOptions ['woo_pdf_title_total'], 'value' => (doble) $ this-> orderData-> order_total,); }
- Busque la función render_left_block y reemplace el siguiente código:
if (class_exists ('WOOCS')) {$ blocks = array ('amount_in_words' => array ('title' => $ this-> invoiceOptions ['woo_pdf_title_amount_in_words'], 'text' => $ this-> get_amount_in_words (( double) WOOCS :: normalize_order_data ($ this-> orderData-> id, $ this-> orderData-> order_total), $ this-> invoiceOptions),),); } else {$ blocks = array ('amount_in_words' => array ('title' => $ this-> invoiceOptions ['woo_pdf_title_amount_in_words'], 'text' => $ this-> get_amount_in_words ((doble) $ this-> orderData -> order_total, $ this-> invoiceOptions),),); }
- Vaya a la función amount_in_words y reemplace el siguiente código:
if (class_exists ('WOOCS')) {$ moneda = get_post_meta ($ this-> orderData-> id, '_woocs_order_currency', TRUE); if (! $ self) {$ string. = ''; $ cadena. = $ moneda; }} else {if (! $ self) {$ string. = ''; $ cadena. = _n ('dólar', 'dólares', $ número, 'woo_pdf'); }}
¡Eso es todo!