Skip to content

Commit

Permalink
Added github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ole1986 committed May 11, 2023
1 parent 0c0299f commit 41a3090
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 13 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/release-on-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Generate Release Notes

on:
push:
tags:
- v*
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install [email protected] -g
- name: Write PreRelease Notes
env:
GREN_GITHUB_TOKEN: ${{ secrets.ACTIONS }}
GITHUB_EVENT_REF: ${{ github.event.ref }}
run: |
tagname="${GITHUB_EVENT_REF/refs\/tags\//}"
gren release --override -d --tags=$tagname
18 changes: 18 additions & 0 deletions .github/workflows/wordpress-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy to WordPress.org
on:
release:
types: [published]
jobs:
build:
if: "!github.event.release.prerelease"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: git config --system --add safe.directory /github/workspace
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@master
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: wc-rearrange-order-items
ASSETS_DIR: assets
25 changes: 25 additions & 0 deletions .grenrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

function getAuthor(placeholders) {
if (placeholders.author === 'ole1986') {
// skip owner
return '';
}

if (placeholders.author === null) {
// skip when no author could be found
return '';
}

return `- @${placeholders.author}`;
}

function parseCommitLine(placeholders) {
return `- ${placeholders.message} ${getAuthor(placeholders)}`
}

module.exports = {
dataSource: "commits",
"template": {
commit: parseCommitLine
}
}
Binary file added Resources/wc-rearrange-order-items.afdesign
Binary file not shown.
Binary file added assets/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== WC Order Item Rearrange ===
=== Rearrange Order Items for WooCommerce ===
Contributors: ole1986
Tags: woocommerce, WC, rearrange, order items, orders, sorting, reorder
Requires at least: 3.1
Tested up to: 6.2
Stable tag: trunk
Stable tag: 1.0.4
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
21 changes: 10 additions & 11 deletions wc-orderitem-rearrange.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
/*
* Plugin Name: WC Rearrange Order Items
* Plugin Name: Rearrange Order Items for WooCommerce
* Description: Rearrange Woocommerce Order Item from admin backend
* Version: 1.0.0
* Version: 1.0.4
* Author: ole1986 <[email protected]>
* Author URI: https://github.com/ole1986/wc-orderitem-rearrange
* Plugin URI: https://github.com/ole1986/wc-orderitem-rearrange/releases
* Text Domain: wc-orderitem-rearrange
*
* WC requires at least: 3.0.0
* WC tested up to: 7.0
* WC tested up to: 7.5
*/

namespace Ole1986\WcOrderItemRearrange;
Expand Down Expand Up @@ -44,9 +44,8 @@ public function DoAjax()
$item_id = intval($_POST['item_id']);
$direction = intval($_POST['direction']);

if (empty($item_id)) {
wp_die();
}
if (empty($item_id)) wp_die();
if (is_null($direction)) wp_die();

$orderItem = new \WC_Order_Item_Product($item_id);
$order = wc_get_order($orderItem->get_order_id());
Expand All @@ -59,12 +58,12 @@ public function DoAjax()

if (!$swap_id) return;

$results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id IN({$item_id}, {$swap_id})", OBJECT);
$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE order_item_id = %d OR order_item_id = %d", $item_id, $swap_id), OBJECT);
$meta_ids = array_column($results, 'meta_id');

$wpdb->query("UPDATE {$wpdb->prefix}woocommerce_order_itemmeta SET order_item_id = IF(order_item_id = {$item_id}, {$swap_id}, {$item_id}) WHERE meta_id IN (" . implode(',', $meta_ids) . ")");
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}woocommerce_order_itemmeta SET order_item_id = IF(order_item_id = %d, %d, %d) WHERE meta_id IN (" . implode(',', $meta_ids) . ")", $item_id, $swap_id, $item_id));

$results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id IN({$item_id}, {$swap_id})", OBJECT);
$results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id = %d OR order_item_id = %d", $item_id, $swap_id), OBJECT);
$resultIds = array_column($results, 'order_item_id');

foreach ($results as $item) {
Expand All @@ -79,8 +78,8 @@ public function add_item_mover($item_id, $item, $product)
$css = 'font-size:1.2em; margin-right: 0.5em; padding: 0.2em; text-decoration:none';
?>
<div style="margin-top: 1em;">
<a href="javascript:void(0)" style="<?php echo $css ?>" onclick="WcOrderItemRearrange.MoveOrderItem(this, <?php echo $item_id ?>, 0)">⇧</span></a>
<a href="javascript:void(0)" style="<?php echo $css ?>" onclick="WcOrderItemRearrange.MoveOrderItem(this, <?php echo $item_id ?>, 1)">⇩</span></a>
<a href="javascript:void(0)" style="<?php echo esc_attr($css) ?>" onclick="WcOrderItemRearrange.MoveOrderItem(this, <?php echo esc_attr($item_id) ?>, 0)">⇧</span></a>
<a href="javascript:void(0)" style="<?php echo esc_attr($css) ?>" onclick="WcOrderItemRearrange.MoveOrderItem(this, <?php echo esc_attr($item_id) ?>, 1)">⇩</span></a>
</div>
<?php
}
Expand Down

0 comments on commit 41a3090

Please sign in to comment.